Re: PHP 4.0 Bug #7113: count and pointers
| From: | Wico de Leeuw | Date: | Tue, 10 Oct 2000 15:31:24 +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-34597@lists.php.net to get a copy of this message | ||
At 14:05 12-10-00 +0200, Dhr. CaPS Cappert wrote:
Now why would you doNot about modify but about speed Giving count a pointer to a large var should be faster then giving count the large value of the var Wico$blah = count(&$data)the '&' doesn't make sense here. The code above still wouldn't make it make sense. count() doesn't modify, NO SENSE in using it there.
This time difference I had can be achieved like this$file = file("whatever"); $data = &$file; $count = count ($data);(Which seems like the PROPER way to do it.) This was on a binary file (A mp3 size 6.3mb) Running on a Celly 366 / 128M --CaPS On Tue, 10 Oct 2000, Wico de Leeuw wrote: My code makes sense (but you don't see it because this is just a little piece of code from a much lagere script because it was written for a bug database) And with me theres a much bigger time difference maybe is my file different/lagere but the difference is there (and about 1700% slower) there is defintly going somthing wrong. Greetz, Wico At 13:21 12-10-00 +0200, Dhr. CaPS Cappert wrote:Lets make a comparison, you write code that doesn't make sense and you expect php to behave correctly? Its like when you punch a guy for no reason and expect him to shake your hand and leave.. By difference 1 sec .. I meantcount($blah);withoutref took 0.6 seconds.. whereas withref took 2.1 seconds..-- CaPS On Tue, 10 Oct 2000, Wico de Leeuw wrote:At 13:02 12-10-00 +0200, Dhr. CaPS Cappert wrote:I tried this .. however I assigned $blah to &$DATA and did afuturebetter)The difference is about one second.. (granted, still to much..)Hiya 1. It's not right... should have a reason (and faster is almost always2. My test-machine isn't that fast the you realy feel the diffwait one sec or wat almost 25 secs and the file in now "only" 8 meg may be much bigger in thefunctions,i don't think it will get faster then :) Greetz, WicoBear in mind that your code doesn't make sense. I don't see why this is such a problem for you. -- CaPS On Tue, 10 Oct 2000, Wico de Leeuw wrote:At 02:35 10-10-00 -0700, Lars Torben Wilson wrote:wico@cnh.nl writes:I just tried this with a 10MB text file and the followingFrom: wico@cnh.nlOperating system: linuxPHP version: 4.0 Latest CVS (10/10/2000) PHP Bug Type: Performance problemBug 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, Wicotakes 9.0146running 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 secondcausingseconds to run 5 times. This is with the latest CVS.I guess this explains that something is really wrongPerhaps there is something in the file loading itself that ishad tothe problem? For instance, when I was testing this just now, Iwent allabort one run, which left an httpd running full-bore and eating massive megabytes--then I ran another test, and my numberslimitscrewy, since the earlier invocation hadn't hit its 30-secondApache toand was still either loading or counting. I had to restartyou?get things evened out--could something similar be happening totheMy apache uses 60 meg when loading a file into an array this isnormalis doingvery bigbehavior of large array Some thime ago i submited a bug report about array overhead beingI did my test about 10 times with and without the pointer With pointer is just verry slow without you won;t even noticepointerssomething with the array is just guess the somthing wrong with my or phps logic aboutphp-list-admin@lists.php.netphp-list-admin@lists.php.netGreetz, Wico-- +----------------------------------------------------------------+-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail:|Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi|+----------------------------------------------------------------+-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail:-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net