Visite Webhosting Latino, el site sobre alojamiento web.
#32806 : fgets() function is slow - Mombu the Php Forum
Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #32806 : fgets() function is slow
User Name
REGISTER NOW! Mark Forums Read

sponsored links

1 8th June 11:49
External User
Posts: 1
Default #32806 : fgets() function is slow

ID: 32806
Updated by:
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:

Please try using this CVS snapshot:

For Windows:

Previous Comments:

[2005-05-04 23:24:07] peoned at yahoo dot com

without fwrite() it is significantly faster, gives about 5-6 seconds.
But in Perl without print OUT $_; it gives around 1-2 seconds. So it is
still slower in PHP because of fgets().


[2005-05-02 14:25:11]

Can you try your tests with the fwrite() line commented out?


[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:

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]

How long are the lines in your file?


[2005-04-28 01:58:55]

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.


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

Edit this bug report at
  Reply With Quote

  sponsored links


Thread Tools
Display Modes

Copyright 2006 - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -