ID: 19971
Comment by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: *Directory/Filesystem functions
Operating System: any
PHP Version: 4.3.0-dev
New Comment:
Please reopen.
PHP 4.2.2 and 4.2.1 appeared to cause delays as well but
PHP 4.3.0 made Squirrelmail unusable. phpMyAdmin appeared
to be affected as well. Downgrading to PHP 4.0.6 resolved
problem. Not clear if this file() function is culprit, but
system load remained low and Cyrus and MySQL do not appear
to be culprit of the application-level slowdown. (Command
line clients do not experience problems.) NOTE: This does
NOT appear to be resolved by CVS snapshot as of 2002 01-23,
which is contrary to above PHP bug!
Additional information:
Gentoo Linux 1.2, nightly update (gcc 2.95)
Cyrus IMAPd 2.1.11
MySQL 3.23.54a
PHP 4.3.0, 4.2.2, 4.2.1
SquirrelMail 1.2.10
phpMyAdmin 2.3.2 (Gentoo rev 1)
Please also see
http://bugs.gentoo.org/show_bug.cgi?id=14513
Previous Comments:
[2002-10-18 15:40:14] [EMAIL PROTECTED]
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
[2002-10-18 09:59:58] [EMAIL PROTECTED]
I got the following times from a tests I've run on PHP.
The test involved openning a 2.5 meg binary file 1000 times.
The results are everages of several runs.
file_get_contents() - 30.4 seconds (4.3 HEAD)
file() - 99.2 seconds (4.3 HEAD)
file() - 40.3 seconds (4.2.3)
Looks like a VERY serious performance loss to me, I'd even go as far
as to say this is a critical issue that should be resolved before
release.
For reference perpouses a simple C program that freads() entire file to
memory took only 18.5 seconds to run (1000 runs on the same file).
[2002-10-18 07:04:36] [EMAIL PROTECTED]
fgets() is fast.
yohgaki@dev DEV]$ cat t.php
setMarker('Start');
$fp = fopen($filename,'r');
for ($i = 0; $i<100; $i++)
$s = explode("\n", fread($fp, filesize($filename)));
fclose($fp);
$time -> setMarker('fread');
for ($i = 0; $i<100; $i++)
$s = file($filename);
$time -> setMarker('file');
for ($i = 0; $i<100; $i++)
$s = file_get_contents($filename);
$time -> setMarker('file_get_contents');
$fp = fopen($filename,'r');
for ($i = 0; $i<100; $i++)
$s = fgets($fp,filesize($filename));
$time -> setMarker('fgets');
fclose($fp);
[yohgaki@dev DEV]$ ./sapi/cli/php t.php
-
markertime indexex time
perct
-
Start 1034942600.41311100 -
0.00%
-
fread 1034942600.43045000 0.017338991165161
2.68%
-
file 1034942600.95939400 0.52894401550293
81.66%
-
file_get_contents 1034942601.04506900 0.085675001144409
13.23%
-
fgets 1034942601.06049200 0.015423059463501
2.38%
-
Stop 1034942601.06084500 0.00035297870635986
0.05%
-
total - 0.64773404598236
100.00%
-
[yohgaki@dev DEV]$
[2002-10-18 06:50:52] [EMAIL PROTECTED]
Damn Mozilla wont work with buffer normally :(
Lets try again.
Problem: read from a text file into array
1. using fread()+explode()
2. using file()
Here my tests
setMarker('Start');
$fp = fopen("access.log", "r");
$s = explode("\n", fread($fp, filesize("access.log") ) ) ;
fclose($fp);
$time -> setMarker('fread+explode');
$s = file("access.log");
$time -> setMarker('file');
$time -> setMarker('Stop');
$time -> display();
?