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

From: Date: Mon, 19 May 2003 14:40:44 +0000
Subject: #23698 [Opn->Asn]: 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-16466@lists.php.net to get a copy of this message
ID: 23698 Updated by: arnaud@php.net Reported By: dholmes at jccc dot net -Status: Open +Status: Assigned Bug Type: PEAR related Operating System: RH 8 PHP Version: 4.3.1 -Assigned To: +Assigned To: lsmith New Comment: Looks sound to me. Previous Comments: ------------------------------------------------------------------------ [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 (#16466) next »