ID: 38812 Updated by: [EMAIL PROTECTED] Reported By: chad at herballure dot com -Status: Open +Status: Closed Bug Type: Performance problem Operating System: Linux (SuSE 9.2) PHP Version: 5CVS-2006-09-13 (snap) New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-09-14 15:23:58] chad at herballure dot com Tony, that seems to be your problem. The Web server and firewall have certainly been running and unmodified since this bug report was opened, and the rest of the world seems to have no trouble getting there. ------------------------------------------------------------------------ [2006-09-14 08:33:21] judas dot iscariote at gmail dot com 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); } ?> ------------------------------------------------------------------------ [2006-09-14 08:20:20] [EMAIL PROTECTED] # telnet www.sapphirepaw.org 80 Trying 68.178.174.117... telnet: connect to address 68.178.174.117: Connection refused ------------------------------------------------------------------------ [2006-09-14 00:51:25] judas dot iscariote at gmail dot com 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 ) ------------------------------------------------------------------------ [2006-09-14 00:25:54] judas dot iscariote at gmail dot com ==== 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 =========== [EMAIL PROTECTED]:~/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 ) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/38812 -- Edit this bug report at http://bugs.php.net/?id=38812&edit=1