php Readfile vs include
来源:百度文库 编辑:神马文学网 时间:2024/04/20 15:49:42
http://blog.iyi.cn/start/2007/04/php_readfile_vs_include.html
去年就曾经测试过php filesystem相关函数和include require的性能,今天无意间看到国外一个更全面的对比,显然include和require是最慢的。所以尽量少用include,尤其是作为缓存,最好还是用文本缓存,我原以为直接缓存为php脚本速度比较快,后来测试才发现include效率很低。 出处:http://www.raditha.com/wiki/Readfile_vs_include Function Brief Description
string file_get_contents ( string filename [, int use_include_path]) Reads entire file into a string
int fpassthru ( resource handle) Output all remaining data on a file pointer
string fgets ( resource handle [, int length]) Gets line from file pointer
array file ( string filename [, int use_include_path]) Reads entire file into an array
require(string filename) include(string filename) require_once(string filename) include_once(string filename) includes and evaluates the specific file.
int readfile ( string filename [, int use_include_path]) Outputs a file
Function Sample Usage Time (s) Memory (b)
file_get_contents echo file_get_contents($filename); 0.00564 1067856
fpassthru fpassthru($fp); 0.00184 20032
fgets $fp = fopen($filename,"rb"); while(!feof($fp)) { echo fgets($fp); } 0.07190 30768
file echo join("",file($filename)); 0.06464 2185624
require_once require_once($filename); 0.08065 2067696
include include($filename); 0.08202 2067696
readfile readfile($filename); 0.00191 19208
Function Time (s) Memory (b)
32Kb File 1Mb File 32Kb File 1Mb File
file_get_contents 0.00152 0.00564 52480 1067856
fpassthru 0.00117 0.00184 20016 20032
fgets 0.00195 0.07190 30760 30768
file 0.00157 0.06464 87344 2185624
require_once 0.00225 0.08065 67992 2067696
include 0.00222 0.08202 67928 2067624
readfile 0.00117 0.00191 19192 19208
去年就曾经测试过php filesystem相关函数和include require的性能,今天无意间看到国外一个更全面的对比,显然include和require是最慢的。所以尽量少用include,尤其是作为缓存,最好还是用文本缓存,我原以为直接缓存为php脚本速度比较快,后来测试才发现include效率很低。 出处:http://www.raditha.com/wiki/Readfile_vs_include Function Brief Description
string file_get_contents ( string filename [, int use_include_path]) Reads entire file into a string
int fpassthru ( resource handle) Output all remaining data on a file pointer
string fgets ( resource handle [, int length]) Gets line from file pointer
array file ( string filename [, int use_include_path]) Reads entire file into an array
require(string filename) include(string filename) require_once(string filename) include_once(string filename) includes and evaluates the specific file.
int readfile ( string filename [, int use_include_path]) Outputs a file
Function Sample Usage Time (s) Memory (b)
file_get_contents echo file_get_contents($filename); 0.00564 1067856
fpassthru fpassthru($fp); 0.00184 20032
fgets $fp = fopen($filename,"rb"); while(!feof($fp)) { echo fgets($fp); } 0.07190 30768
file echo join("",file($filename)); 0.06464 2185624
require_once require_once($filename); 0.08065 2067696
include include($filename); 0.08202 2067696
readfile readfile($filename); 0.00191 19208
Function Time (s) Memory (b)
32Kb File 1Mb File 32Kb File 1Mb File
file_get_contents 0.00152 0.00564 52480 1067856
fpassthru 0.00117 0.00184 20016 20032
fgets 0.00195 0.07190 30760 30768
file 0.00157 0.06464 87344 2185624
require_once 0.00225 0.08065 67992 2067696
include 0.00222 0.08202 67928 2067624
readfile 0.00117 0.00191 19192 19208
php Readfile vs include
php Readfile vs include
jsp 静态include和动态include
php
再谈 #include file 和 #include virtual的区别
再谈 #include file 和 #include virtual的区别
C/C++#include 机制简述
C Header File Include Patterns
Contain 与include 辨析pp
给javascript加入include(import)命令
JSP中的include的两种用法
【转】 , , and
php 跳转
PHP & memcached
php教程
php编码
php实验室
socket.php
php语法
PHP echo
阳光锈了-ASP中#Include命令简介
UML用例图中包含(include)、扩展(extend)和泛化(generalizati...
转贴:UML用例图中包含(include)、扩展(extend)和泛化(generaliz...
PHP 文件锁flock - 聊聊PHP - php,freebsd,javascript