|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-02 09:32 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
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().