Re: PHP 4.0 Bug #7113: count and pointers

From: Date: Tue, 10 Oct 2000 09:35:57 +0000
Subject: Re: PHP 4.0 Bug #7113: count and pointers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-34558@lists.php.net to get a copy of this message
wico@cnh.nl writes: > From: wico@cnh.nl > Operating system: linux > PHP version: 4.0 Latest CVS (10/10/2000) > PHP Bug Type: Performance problem > Bug description: count and pointers > > Hiya > > $ADLIB_FILE is a file, size = 9mb > > $ADLIB_DATA = file($ADLIB_FILE); > $ADLIB_COUNT = count($ADLIB_DATA); > echo time() - $test . " seconden<BR>\n\n"; > die(); > > takes 17 secs > > $ADLIB_DATA = file($ADLIB_FILE); > $ADLIB_COUNT = count(&$ADLIB_DATA); > echo time() - $test . " seconden<BR>\n\n"; > die(); > this takes 27 secs? > > shouldn't this be faster the the first one? > > Greetz, > > Wico I just tried this with a 10MB text file and the following functions, running each one 5 times: $file = file('/home/torben/INBOX'); function with_ref() { global $file; $count = count(&$file); echo "$count<br>\n"; } function without_ref() { global $file; $count = count($file); echo "$count<br>\n"; } The first one runs 5 times in 0.00146 seconds; the second takes 9.0146 seconds to run 5 times. This is with the latest CVS. Perhaps there is something in the file loading itself that is causing the problem? For instance, when I was testing this just now, I had to abort one run, which left an httpd running full-bore and eating massive megabytes--then I ran another test, and my numbers went all screwy, since the earlier invocation hadn't hit its 30-second limit and was still either loading or counting. I had to restart Apache to get things evened out--could something similar be happening to you? -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.dev (#34558) next »