Created
April 10, 2023 22:00
-
-
Save nielsdos/e4fe296cb0300708bd1b2e44c57134b9 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
<?php | |
$start = microtime(true); | |
$input = range(0, 1000); | |
for ($i = 0; $i < 1000; $i++) { | |
$a = array_unique($input, SORT_REGULAR); | |
} | |
$delta = microtime(true) - $start; | |
echo $delta, "\n"; | |
$start = microtime(true); | |
function &gen_ref(&$x) { | |
return $x; | |
} | |
$input_with_refs = []; | |
for ($i = 0; $i < 1000; $i++) { | |
$input_with_refs[] = &gen_ref($i); | |
} | |
for ($i = 0; $i < 1000; $i++) { | |
$a = array_unique($input_with_refs, SORT_REGULAR); | |
} | |
$delta = microtime(true) - $start; | |
echo $delta, "\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment