Skip to content

Instantly share code, notes, and snippets.

@rtheunissen
Last active June 30, 2018 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtheunissen/c53d2c81b26a56867de82d899769759c to your computer and use it in GitHub Desktop.
Save rtheunissen/c53d2c81b26a56867de82d899769759c to your computer and use it in GitHub Desktop.
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