Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP Bug #63217 Benchmark Script
<?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