Last active
September 16, 2016 00:09
-
-
Save jesseschalken/f77a97cd031ec9da97c5009f27d937c7 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 | |
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