3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rand = []; $randKeys = []; $max = 1000; for ($i = 0; $i < $max; $i++) { $v = bin2hex(random_bytes(10)); $rand[] = $v; $randKeys[$v] = $v; } // $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $keys = []; for ($j = 0; $j < $max; $j++) { $keys[] = $rand[$j]; } } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); // $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $keys = array_keys($randKeys); } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max);
Output for 8.1.1
Took 0.0000314 seconds per execution Took 0.0000054 seconds per execution
Output for 8.1.0
Took 0.0000313 seconds per execution Took 0.0000054 seconds per execution
Output for 8.0.14
Took 0.0000310 seconds per execution Took 0.0000056 seconds per execution
Output for 7.3.23, 8.0.7, 8.0.13
Took 0.0000307 seconds per execution Took 0.0000054 seconds per execution
Output for 8.0.12
Took 0.0000310 seconds per execution Took 0.0000052 seconds per execution
Output for 7.3.28, 8.0.11
Took 0.0000311 seconds per execution Took 0.0000057 seconds per execution
Output for 8.0.10
Took 0.0000320 seconds per execution Took 0.0000055 seconds per execution
Output for 8.0.9
Took 0.0000309 seconds per execution Took 0.0000052 seconds per execution
Output for 8.0.8
Took 0.0000307 seconds per execution Took 0.0000053 seconds per execution
Output for 8.0.5 - 8.0.6
Took 0.0000309 seconds per execution Took 0.0000053 seconds per execution
Output for 8.0.3
Took 0.0000305 seconds per execution Took 0.0000054 seconds per execution
Output for 8.0.2
Took 0.0000309 seconds per execution Took 0.0000057 seconds per execution
Output for 7.3.14, 8.0.1
Took 0.0000317 seconds per execution Took 0.0000055 seconds per execution
Output for 8.0.0
Took 0.0000308 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.20, 7.4.27
Took 0.0000330 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.26
Took 0.0000327 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.16, 7.4.25
Took 0.0000329 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.24
Took 0.0000344 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.23
Took 0.0000335 seconds per execution Took 0.0000057 seconds per execution
Output for 7.4.13, 7.4.22
Took 0.0000332 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.10, 7.4.21
Took 0.0000333 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.19
Took 0.0000338 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.18
Took 0.0000335 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.1, 7.4.15
Took 0.0000328 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.14
Took 0.0000335 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.12
Took 0.0000335 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.11
Took 0.0000329 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.9
Took 0.0000336 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.3, 7.4.8
Took 0.0000327 seconds per execution Took 0.0000053 seconds per execution
Output for 7.4.7
Took 0.0000326 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.6
Took 0.0000329 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.5
Took 0.0000324 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.4
Took 0.0000328 seconds per execution Took 0.0000055 seconds per execution
Output for 7.4.2
Took 0.0000331 seconds per execution Took 0.0000054 seconds per execution
Output for 7.4.0
Took 0.0000324 seconds per execution Took 0.0000055 seconds per execution
Output for 7.3.33
Took 0.0000312 seconds per execution Took 0.0000056 seconds per execution
Output for 7.3.32
Took 0.0000332 seconds per execution Took 0.0000057 seconds per execution
Output for 7.3.31
Took 0.0000330 seconds per execution Took 0.0000056 seconds per execution
Output for 7.3.21, 7.3.30
Took 0.0000318 seconds per execution Took 0.0000057 seconds per execution
Output for 7.3.17, 7.3.29
Took 0.0000306 seconds per execution Took 0.0000055 seconds per execution
Output for 7.3.27
Took 0.0000314 seconds per execution Took 0.0000058 seconds per execution
Output for 7.3.20, 7.3.26
Took 0.0000311 seconds per execution Took 0.0000055 seconds per execution
Output for 7.3.13, 7.3.25
Took 0.0000310 seconds per execution Took 0.0000054 seconds per execution
Output for 7.3.24
Took 0.0000308 seconds per execution Took 0.0000055 seconds per execution
Output for 7.3.22
Took 0.0000322 seconds per execution Took 0.0000056 seconds per execution
Output for 7.3.19
Took 0.0000308 seconds per execution Took 0.0000057 seconds per execution
Output for 7.3.18
Took 0.0000307 seconds per execution Took 0.0000055 seconds per execution
Output for 7.3.16
Took 0.0000332 seconds per execution Took 0.0000056 seconds per execution
Output for 7.3.15
Took 0.0000312 seconds per execution Took 0.0000054 seconds per execution

preferences:
73.2 ms | 474 KiB | 5 Q