Bug #69440 [NEW]: Perfomance of function count() with array getted by references

From: Date: Mon, 13 Apr 2015 22:39:45 +0000
Subject: Bug #69440 [NEW]: Perfomance of function count() with array getted by references
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192028@lists.php.net to get a copy of this message
From: mikheev at 179 dot ru Operating system: PHP version: 5.6.8RC1 Package: Performance problem Bug Type: Bug Bug description:Perfomance of function count() with array getted by references Description: ------------ If I execute count($arr) from function foo(&$arr), it will have a complexity O(n) (feels like) instead of the expected O(1), where n is count of elements in array. Is it correct? Why? Test script: --------------- http://sandbox.onlinephpfunctions.com/code/f2d23edf84bbfe841d3bffda8373af8d07e51a19 Expected result: ---------------- FooWithArrayCopy: 0.00056791305541992 FooWithArrayCopy: 0.00046791305541992 Actual result: -------------- FooWithArrayCopy: 0.00056791305541992 FooWithReference: 2.7791709899902 -- Edit bug report at https://bugs.php.net/bug.php?id=69440&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69440&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69440&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69440&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69440&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69440&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69440&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69440&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69440&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69440&r=support Expected behavior: https://bugs.php.net/fix.php?id=69440&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69440&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69440&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69440&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69440&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69440&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69440&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69440&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69440&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69440&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69440&r=mysqlcfg

« previous php.bugs (#192028) next »