Skip to content

Instantly share code, notes, and snippets.

@jesseschalken
Last active September 16, 2016 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseschalken/f77a97cd031ec9da97c5009f27d937c7 to your computer and use it in GitHub Desktop.
Save jesseschalken/f77a97cd031ec9da97c5009f27d937c7 to your computer and use it in GitHub Desktop.
<?php
ini_set('memory_limit', '-1');
function is_vector(array $x) {
return array_values($x) === $x;
}
function test($name, array $x) {
$t = microtime(true);
$r = is_vector($x);
$t = microtime(true) - $t;
printf("is_vector() === %d, %.6f (%s)\n", $r, $t, $name);
}
function make_array($size) {
return ;
}
function do_test($size) {
test("$size elements", \array_fill(0, $size, true));
}
do_test(0);
do_test(1);
do_test(10);
do_test(100);
do_test(1000);
do_test(10000);
do_test(100000);
do_test(1000000);
do_test(10000000);
do_test(100000000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment