Bug #53242 [NEW]: count() slow for global / static arrays

From: Date: Thu, 04 Nov 2010 16:50:28 +0000
Subject: Bug #53242 [NEW]: count() slow for global / static arrays
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155763@lists.php.net to get a copy of this message
From: Operating system: Arch Linux PHP version: 5.3.3 Package: Performance problem Bug Type: Bug Bug description:count() slow for global / static arrays Description: ------------ When the arrays are defined global or static, the sizeof() / count method suddenly gets very slow. Test script: --------------- <?php $items = range(0, 50000); $times = 200; $time = microtime(true); for ($i = 0; $i < $times; $i++) { $foo = sizeof($items); } printf("Non-global access: %.2fs\n", microtime(true) - $time); $time = microtime(true); for ($i = 0; $i < $times; $i++) { test_global(); } printf("Global access: %.2fs\n", microtime(true) - $time); function test_global() { global $items; $foo = sizeof($items); } Expected result: ---------------- % php array-test.php Non-global access: 0.00s Global access: 0.00s Actual result: -------------- % php array-test.php Non-global access: 0.00s Global access: 2.73s -- Edit bug report at http://bugs.php.net/bug.php?id=53242&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53242&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53242&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53242&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53242&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53242&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53242&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53242&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53242&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53242&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53242&r=support Expected behavior: http://bugs.php.net/fix.php?id=53242&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53242&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53242&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53242&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53242&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53242&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53242&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53242&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53242&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53242&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53242&r=mysqlcfg

« previous php.bugs (#155763) next »