#23698 [Asn]: easy to fix "strlen in for loop" causing serious delay in LARGE sites
| From: | lsmith@php.net | Date: | Mon, 19 May 2003 14:59:27 +0000 |
| Subject: | #23698 [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-16468@lists.php.net to get a copy of this message | ||
ID: 23698
Updated by: lsmith@php.net
Reported By: dholmes at jccc dot net
Status: Assigned
Bug Type: PEAR related
Operating System: RH 8
PHP Version: 4.3.1
-Assigned To: lsmith
+Assigned To: ssb
New Comment:
Sure should be changed (hope that he was just talking about changing
the for loop line and not the 3 before that).
Previous Comments:
------------------------------------------------------------------------
[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