Last active
February 25, 2018 09:59
-
-
Save jens1o/621c1307ee0b9d618839211688d46dba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$emptyArray = []; | |
$numberArray = range(0, 10000); | |
$charArray = array_merge(range('a', 'z'), range('A', 'Z')); | |
foreach([$emptyArray, $numberArray, $charArray] as $array) { | |
$startTime = microtime(true); | |
for ($i = 0; $i <= 100000; $i++) { | |
if (in_array('', $array, true)) { | |
} | |
} | |
$endTime = microtime(true); | |
echo 'Took ' . round($endTime - $startTime, 2) . 's with strict compare' . PHP_EOL; | |
$startTime = microtime(true); | |
for ($i = 0; $i <= 100000; $i++) { | |
if (in_array('', $array)) { | |
} | |
} | |
$endTime = microtime(true); | |
echo 'Took ' . round($endTime - $startTime, 2) . 's without strict compare' . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment