#32806 [Asn->Fbk]: fgets() function is slow
| From: | wez@php.net | Date: | Mon, 02 May 2005 12:25:12 +0000 |
| Subject: | #32806 [Asn->Fbk]: fgets() function is slow | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78522@lists.php.net to get a copy of this message | ||
ID: 32806
Updated by: wez@php.net
Reported By: peoned at yahoo dot com
-Status: Assigned
+Status: Feedback
Bug Type: Performance problem
Operating System: Linux
PHP Version: 5.0.4
Assigned To: wez
New Comment:
Can you try your tests with the fwrite() line commented out?
Previous Comments:
------------------------------------------------------------------------
[2005-04-28 07:30:31] peoned at yahoo dot com
I did an
echo strlen($line).",";
Here are the lengths for some of the first few lines:
42,7,18,11,71,13,8,7,42,7,20,11,73,70,68,63,13,8,7
It looks pretty much like this for the rest of the file. Lines between
1 and 100 chars in length.
Note: It isn't the start up cost for sure because I measured the time
just around the while loop with the same results.
------------------------------------------------------------------------
[2005-04-28 04:37:03] wez@php.net
How long are the lines in your file?
------------------------------------------------------------------------
[2005-04-28 01:58:55] iliaa@php.net
Startup costs could be 8 seconds or more depending on the extensions
you are loading. That said PHP's fgets() is still slower then Perl's
because of it's implementation that does not wrap the C library fgets()
or getline(), but rather uses custom code.
------------------------------------------------------------------------
[2005-04-24 20:20:54] peoned at yahoo dot com
I don't agree that this is a bogus bug. You want to tell me that the
start up cost is responsible for 8 seconds? Than you have a performance
bug with your start up cost. Run it with fread($fin, 1024); where did
the start up cost go? Simplifying the script to while($line =
fgets($fin)){} doesn't help either. And automatic detection of new
lines is disabled. Did you run some of your own tests?
------------------------------------------------------------------------
[2005-04-24 18:25:52] iliaa@php.net
Performance is equivalent when you simplify your PHP script and stop
timing php's start-up costs. Also make sure that automatic detection of
new lines is disabled.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/32806
--
Edit this bug report at http://bugs.php.net/?id=32806&edit=1