#23698 [NEW]: easy to fix "strlen in for loop" causing serious delay in LARGE sites
| From: | dholmes at jccc dot net | Date: | Mon, 19 May 2003 13:39:18 +0000 |
| Subject: | #23698 [NEW]: easy to fix "strlen in for loop" causing serious delay in LARGE sites | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-16463@lists.php.net to get a copy of this message | ||
From: dholmes at jccc dot net
Operating system: RH 8
PHP version: 4.3.1
PHP Bug Type: PEAR related
Bug description: easy to fix "strlen in for loop" causing serious delay in LARGE sites
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 bug report at http://bugs.php.net/?id=23698&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23698&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23698&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23698&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23698&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23698&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23698&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23698&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23698&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23698&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23698&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23698&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23698&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23698&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23698&r=gnused