Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Benchmark params
$runs = 100000000;
// Gen test array
$strMatch = 'test string';
echo 'Benchmark runs: ' . $runs . PHP_EOL;
// Benchmark isset
$timeStart = microtime(true);
for ($i = 0; $i < $runs; $i++) {
$strMatch === "test string";
}
echo 'double quotes: ' . (microtime(true) - $timeStart) . PHP_EOL;
// Benchmark array_key_exist
$timeStart = microtime(true);
for ($i = 0; $i < $runs; $i++) {
$strMatch === 'test string';
}
echo 'single quotes: ' . (microtime(true) - $timeStart) . PHP_EOL;
@postpersonality

This comment has been minimized.

Copy link
Owner Author

commented Jan 28, 2016

Benchmark runs: 100000000 double quotes: 11.21027803421 single quotes: 11.260735034943
Benchmark runs: 100000000 double quotes: 11.485301971436 single quotes: 11.39031291008
Benchmark runs: 100000000 double quotes: 11.485301971436 single quotes: 11.39031291008

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.