Yasuo Ohgaki wrote:
Tal Peer wrote:

hello,
this patch tries to fix the performance issues described in bug #19771.
i cannot benchmark this at the moment, so if anyone can, please do.
the patch is available at http://tal.madcode.org/file.c.patch

and thanks to wez :)

Getting better, but it still too slow somehow...
Never mind. There is stupid mistake in the script...
It should be Ok.

[yohgaki@dev DEV]$ ./sapi/cli/php  t.php
-------------------------------------------------------------------------
marker                time index            ex time               perct
-------------------------------------------------------------------------
Start                 1034947649.40024700   -                       0.00%
-------------------------------------------------------------------------
fread                 1034947649.82932800   0.42908096313477       44.84%
-------------------------------------------------------------------------
file                  1034947650.23224900   0.40292108058929       42.11%
-------------------------------------------------------------------------
file_get_contents     1034947650.32007600   0.08782696723938        9.18%
-------------------------------------------------------------------------
fgets                 1034947650.35698600   0.036910057067871       3.86%
-------------------------------------------------------------------------
Stop                  1034947650.35716300   0.00017690658569336     0.02%
-------------------------------------------------------------------------
total                 -                     0.956915974617        100.00%
-------------------------------------------------------------------------


[yohgaki@dev DEV]$ cat t.php
<?php
$filename = '/var/log/httpd/error_log.1';

require("Benchmark/Timer.php");
$time = new Benchmark_Timer;

$time -> setMarker('Start');

for ($i = 0; $i<100; $i++) {
  $fp = fopen($filename,'r');
  $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');

for ($i = 0; $i<100; $i++) {
  $fp = fopen($filename,'r');
  //$s = explode("\n", fgets($fp,filesize($filename)));
  $s = explode("\n", fgets($fp));
  fclose($fp);
}
$time -> setMarker('fgets');

$time -> setMarker('Stop');
$time -> display();
?>


[yohgaki@dev DEV]$


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to