Skip to content

Instantly share code, notes, and snippets.

@nielsdos
Created April 10, 2023 22:00
Show Gist options
  • Save nielsdos/e4fe296cb0300708bd1b2e44c57134b9 to your computer and use it in GitHub Desktop.
Save nielsdos/e4fe296cb0300708bd1b2e44c57134b9 to your computer and use it in GitHub Desktop.
<?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