From: alex at raintree dot ee
Operating system: Windows Server 2003
PHP version: 5.2CVS-2008-03-31 (snap)
PHP Bug Type: Arrays related
Bug description: reading non-existing value from multidimentional array
Description:
------------
Noticed serious performance issues while reading non-existing values from
multi-dimensional array.
Adding ISSET() check before the array read makes the script at least 3
times faster.
However the main concern is that there are lots of non-optimized scripts
that do not have ISSET() around multi-dimensional arrays.
Reproduce code:
---------------
error_reporting(0);
$start = date('H:m:s');
$myArr = array('a');
$test = 'a';
// performance killer loop
for($i = 0; $i < 1000000; $i++)
if ($myArr[$test][$fieldName] == 5);
/* optimized code
if (isset($myArr[$test][$fieldName]) && $myArr[$test][$fieldName] == 5)
*/
$end = date('H:m:s');
echo $start . ' ' . $end;
Expected result:
----------------
I expect the code with ISSET (commented out) run close to as fast as the
code without ISSET.
Actual result:
--------------
Serious performance difference while running code that has ISSET() around
multi-dimensional array read vs. code without ISSET().
--
Edit bug report at http://bugs.php.net/?id=44579&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44579&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44579&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44579&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44579&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44579&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44579&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44579&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44579&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44579&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44579&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44579&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44579&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44579&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44579&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44579&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44579&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44579&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44579&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44579&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44579&r=mysqlcfg