ID: 19971 Comment by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: *Directory/Filesystem functions Operating System: win_xp PHP Version: 4.2.3 New Comment:
<?php require("Benchmark/Timer.php"); $time = new Benchmark_Timer; $time -> setMarker('Start'); $fp = fopen("access.log", "r"); $s = explode("\n", fread($fp, filesize("access.log") ) ) ; fclose($fp); $time -> setMarker('fread'); $s = file("access.log"); $time -> setMarker('file'); $time -> setMarker('Stop'); $time -> display(); ?> access.log 16Mb fread + explode faster when file(). Hmmm... time indexex time% Start1034933111.79707300-0.00% fread1034933112.398477000.60140417.87% file1034933115.162048002.76357182.12% Stop1034933115.162183000.0001350.00% total-3.365110100.00% Previous Comments: ------------------------------------------------------------------------ [2002-10-18 04:11:52] [EMAIL PROTECTED] It slow even with text files Sorry for Photoshop.exe-example I test it even with apache/logs/access.log ------------------------------------------------------------------------ [2002-10-18 03:53:15] [EMAIL PROTECTED] file() is not binary safe; you should not use it on binary files. When testing the snapshot, try the new file_get_contents() function too, which is 100% binary safe. $s = file_get_contents(); ------------------------------------------------------------------------ [2002-10-18 03:05:02] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php4-latest.tar.gz For Windows: http://snaps.php.net/win32/php4-win32-latest.zip Ops, wrong quick fix. ------------------------------------------------------------------------ [2002-10-18 03:04:43] [EMAIL PROTECTED] Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. ------------------------------------------------------------------------ [2002-10-18 02:48:08] [EMAIL PROTECTED] This function is extrimally slow read a file. On php4.0.4pl1 it much faster (about 100-1000x)!!! :( <?php require("Benchmark/Timer.php"); $time = new Benchmark_Timer; $time -> setMarker('Start'); $fp = fopen("Photoshop.exe", "r"); //$s = explode("\n", fread($fp, filesize("Photoshop.exe") ) ) ; fclose($fp); //print_r($s); $time -> setMarker('fread'); $s = file("Photoshop.exe"); $time -> setMarker('file'); $time -> setMarker('Stop'); $time -> display(); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19971&edit=1