Last active
June 30, 2018 20:06
-
-
Save rtheunissen/c53d2c81b26a56867de82d899769759c to your computer and use it in GitHub Desktop.
PHP Bug #63217 Benchmark Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See https://github.com/php/php-src/pull/3351 | |
$arr = [ | |
"foo" => true, | |
"foobar" => 3, | |
"elePHPant" => "qux", | |
"long_key_name" => "something contrived", | |
"123" => 76, | |
"001234" => null, | |
"6276372623" => "another" | |
]; | |
$start = microtime(true); | |
for ($i = 0; $i < 30000000; $i++) { | |
$foo = $arr["foo"]; | |
$arr["foo"] = $foo; | |
$exists = isset($arr["foo"]); | |
$foobar = $arr["foobar"]; | |
$arr["foobar"] = $foobar; | |
$exists = isset($arr["foobar"]); | |
$elePHPant = $arr["elePHPant"]; | |
$arr["elePHPant"] = $elePHPant; | |
$exists = isset($arr["elePHPant"]); | |
$long_key_name = $arr["long_key_name"]; | |
$arr["long_key_name"] = $long_key_name; | |
$exists = isset($arr["long_key_name"]); | |
$low_ascii_codepoint = $arr["!#"]; | |
$arr["!#"] = $low_ascii_codepoint; | |
$exists = isset($arr["!#"]); | |
} | |
$end = microtime(true); | |
echo basename(PHP_BINARY), ": ", $end - $start, "s", PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment