|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-05 02:40 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2010-11-05 02:40 UTC] cataphract@php.net
[2010-12-01 17:58 UTC] ceo at l-i-e dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 20:00:01 2025 UTC |
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