|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-09-13 15:58 UTC] chad at herballure dot com
Description: ------------ array_key_exists takes about 16 times longer in PHP 5.2-200609131430 than it does in 5.1.[246]. Reproduce code: --------------- http://www.sapphirepaw.org/ake_bug.txt (depends on Benchmark_Iterate in PEAR) Expected result: ---------------- The 5.1.x series produces numbers like: ake_test: Array ( [0] => 0.406023979187 [1] => 0.285789966583 [2] => 0.236785173416 [3] => 0.22957110405 ) Actual result: -------------- Yesterday's and todays 5.2 snapshots produce numbers like: ake_test: Array ( [0] => 4.45166897774 [1] => 4.08239388466 [2] => 4.0640411377 [3] => 4.06054711342 ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
==== PHP 5_2 debug mode ====== php array_key_exists.php ake_test: Array ( [0] => 222.61117291451 [1] => 228.49721598625 [2] => 235.83725214005 [3] => 415.96051192284 ) is1_test: Array ( [0] => 1.2712152004242 [1] => 1.3619549274445 [2] => 1.3896028995514 [3] => 1.262256860733 ) is2_test: Array ( [0] => 0.95932698249817 [1] => 0.86532402038574 [2] => 0.9735701084137 [3] => 0.85658717155457 ) ======== php 5.1.6 no debug =========== cristian@hell:~/php-src> php5 array_key_exists.php ake_test: Array ( [0] => 0.23552083969116 [1] => 0.22312307357788 [2] => 0.22217798233032 [3] => 0.22680497169495 ) is1_test: Array ( [0] => 0.24776816368103 [1] => 0.24320101737976 [2] => 0.2431800365448 [3] => 0.24098587036133 ) is2_test: Array ( [0] => 0.15930700302124 [1] => 0.16577696800232 [2] => 0.15875005722046 [3] => 0.15803599357605 )well, previuos test was not quite right 'cause I was testing a debug build against a non-debug build. this is the correct result === PHP 5_2 no debug, non zts== == ** ./configure --disable-all ** ./sapi/cli/php array_key_exists.php ake_test: Array ( [0] => 61.461007118225 [1] => 58.933461904526 [2] => 67.2141289711 [3] => 60.613692998886 ) is1_test: Array ( [0] => 0.17689299583435 [1] => 0.16376399993896 [2] => 0.22526001930237 [3] => 0.16580605506897 ) is2_test: Array ( [0] => 0.1137011051178 [1] => 0.11136889457703 [2] => 0.11219096183777 [3] => 0.11238098144531 ) ====== PHP 5_1 non debug, non zts === ==== *** ./configure --disable-all ** ==== ~/5.1/php-src> ./sapi/cli/php ~/php-src/array_key_exists.php ake_test: Array ( [0] => 0.13297486305237 [1] => 0.12529993057251 [2] => 0.12710905075073 [3] => 0.12793111801147 ) is1_test: Array ( [0] => 0.15972304344177 [1] => 0.16012096405029 [2] => 0.16134810447693 [3] => 0.16280102729797 ) is2_test: Array ( [0] => 0.10458111763 [1] => 0.10124111175537 [2] => 0.10496115684509 [3] => 0.10187220573425 )here is the test case, in case you can't access it. <?php function ake_test($array, $wanted) { return (array_key_exists($wanted, $array)); } function is1_helper($array, $wanted) { return (isset($array[$wanted])); } function is1_test($array, $wanted) { return (is1_helper($array, $wanted)); } // make function call (as ake must) function is2_test($array, $wanted) { return (isset($array[$wanted])); } // special lang feature, not a function... $A = array(); for($i=1; $i < 2000; $i++) { $A["k{$i}y"] = "val_{$i}_ue"; } // build array to examine $tests = array('ake', 'is1', 'is2'); foreach($tests as $test) { $func = $test . '_test'; $r = array(); // benchmark results echo("$func:\n"); for($outer = 0; $outer < 4; ++$outer) { $starttime = microtime(true); for($inner = 0; $inner < 100000; ++$inner) { $func($A, 'k1388y'); } array_push($r, microtime(true) - $starttime); // record elapsed realtime } print_r($r); } ?>