ID: 32806
Updated by: [EMAIL PROTECTED]
Reported By: peoned at yahoo dot com
-Status: Bogus
+Status: Feedback
Bug Type: Performance problem
Operating System: Linux
PHP Version: 5.0.4
New Comment:
How long are the lines in your file?
Previous Comments:
------------------------------------------------------------------------
[2005-04-28 01:58:55] [EMAIL PROTECTED]
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] [EMAIL PROTECTED]
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.
------------------------------------------------------------------------
[2005-04-24 00:13:01] peoned at yahoo dot com
Perl code:
#!/usr/local/bin/perl
open(IN, "<afe199406");
open(OUT, ">perl_out.txt");
while(<IN>)
{
print OUT $_;
}
close(OUT);
close(IN);
C code:
#include <stdio.h>
#include <string.h>
int main(void)
{
size_t n = 5000;
char *ptr;
FILE *fp;
FILE *fi;
fp = fopen("int.txt", "rb");
fi = fopen("out.txt", "wb");
ptr = (char *)malloc(5000);
int i=0;
while(getline(&ptr,&n,fp) != -1)
{
fwrite(ptr, 1, strlen(ptr), fi);
}
free(ptr);
fclose(fp);
fclose(fi);
}
magic_quotes_runtime was off
------------------------------------------------------------------------
[2005-04-23 23:59:51] [EMAIL PROTECTED]
Can you provide the perl code you used..?
Also, if you have magic_quotes_runtime ini option set to off, it'll be
faster.
------------------------------------------------------------------------
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