Too slow execution time.

From: Date: Sat, 02 Oct 1999 02:52:13 +0000
Subject: Too slow execution time.
Groups: php.dev 
Request: Send a blank email to php-dev+get-11423@lists.php.net to get a copy of this message
I'm using PHP3.0.7. I have a text file of lines that end with "QR=....", and I want to extract the tailing part of each line. My first PHP code was... $lines = file($filename); for ($i = 0; $i < count($lines); $i++) { $query = strstr($line[$i], "QR="); printf("$query\n"); } Alas however, my code run out execution timeout error. (The text file is about 60,000 lines. The code dies at about 3,000'th line, and the lifetime was 30 seconds.) The same thing I did with a Perl code, that seems to be very similar... open(F, "< $filename"); @lines = <F>; # read in each lines into an array close(F); foreach $line (@lines) { if ($line =~ m/QR=(.*)/) { $query = $1; print "$query\n"; } } This Perl code does all the processing in 1.2 seconds. What the hell... Seems to me that Perl's just-in-time compiling works very effectively. Seems to me that "implode()" is also very slow... $buffer = implode("\n", $lines); doesnot end within 30 seconds, if $lines contains more than 3000 lines of text. Perhaps there might be a heavy mem-copy- operation within "implode()" function. I hope, Zend would be as fast as Perl. --KIM Hiongun, a warrior against language barrier.

« previous php.dev (#11423) next »