Created
January 28, 2016 14:25
-
-
Save postpersonality/11f673d1265dce993c43 to your computer and use it in GitHub Desktop.
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
// 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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