ID:               38812
 User updated by:  chad at herballure dot com
 Reported By:      chad at herballure dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Performance problem
 Operating System: Linux (SuSE 9.2)
 PHP Version:      5CVS-2006-09-13 (snap)
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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
)

------------------------------------------------------------------------

[2006-09-13 18:53:53] chad at herballure dot com

Your claim that the link "doesn't work" could not be verified. It
displays the PHP script source code to reproduce the bug, as intended.
We do not feel that running the benchmark and producing the output on
our server is useful.

The code available at the link has been updated to no longer require
PEAR. http://www.sapphirepaw.org/ake_bug.txt

New expected and actual results were generated using this code,
revealing an actual difference between PHP versions of 204x.

Because isset() is a language feature, not a function call, an extra
test was added to determine if function calls are what is expensive.
The answer appears to be "no".

New expected result:
--------------------
ake_test:
Array
(
    [0] => 0.297938108444
    [1] => 0.211642026901
    [2] => 0.16384100914
    [3] => 0.153891801834
)
is1_test:
Array
(
    [0] => 0.193047046661
    [1] => 0.176480054855
    [2] => 0.168280124664
    [3] => 0.171167135239
)
is2_test:
Array
(
    [0] => 0.111315965652
    [1] => 0.112279176712
    [2] => 0.105856180191
    [3] => 0.109282016754
)

New actual result:
------------------
ake_test:
Array
(
    [0] => 36.2062079906
    [1] => 36.0692551136
    [2] => 36.0703611374
    [3] => 36.040956974
)
is1_test:
Array
(
    [0] => 0.17557311058
    [1] => 0.169100999832
    [2] => 0.169121026993
    [3] => 0.169019937515
)
is2_test:
Array
(
    [0] => 0.113948106766
    [1] => 0.108880996704
    [2] => 0.107892036438
    [3] => 0.110790014267
)

------------------------------------------------------------------------

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

Reply via email to