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
