#23698 [Asn->Csd]: easy to fix "strlen in for loop" causing serious delay in LARGE sites

From: Date: Mon, 19 May 2003 20:46:52 +0000
Subject: #23698 [Asn->Csd]: easy to fix "strlen in for loop" causing serious delay in LARGE sites
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16478@lists.php.net to get a copy of this message
ID: 23698 Updated by: ssb@php.net Reported By: dholmes at jccc dot net -Status: Assigned +Status: Closed Bug Type: PEAR related Operating System: RH 8 PHP Version: 4.3.1 Assigned To: ssb New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-05-19 10:52:46] dholmes at jccc dot net Oh certainly...just the for loop. :-) ------------------------------------------------------------------------ [2003-05-19 09:59:26] lsmith@php.net Sure should be changed (hope that he was just talking about changing the for loop line and not the 3 before that). ------------------------------------------------------------------------ [2003-05-19 09:40:43] arnaud@php.net Looks sound to me. ------------------------------------------------------------------------ [2003-05-19 08:39:18] dholmes at jccc dot net I recently discovered apd and I ran it up against our site's framework. Imagine my surprise when I saw that I was hitting strlen 27917 times! It turns out that I heavily use PEAR DB's prepare() functionality. In the current CVS, the prepare function is: function prepare($query) { $tokens = split("[\&\?\!]", $query); $token = 0; $types = array(); for ($i = 0; $i < strlen($query); $i++) { But if I change it to: $length = strlen($query); for ($i = 0; $i < $length; $i++) { I was able to shave almost 2 seconds off of my uncached render times. Don't think for a minute that I don't love PEAR::DB. I appreciate all your hard work and recommend it constantly. Thanks! - Dan ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23698&edit=1

« previous php.pear.dev (#16478) next »