3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php const INT_COUNT = 1000000; // Fill an array with random ints $ints = array(); for ($i = 0; $i < INT_COUNT; $i++){ $ints[] = rand(0, 255); } // Sort the ints sort($ints); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints[$i]; } $finish = microtime(true); printf("Time taken with sort(): %.5f seconds\n", $finish - $start); // Now do it again, but this time use an asort // Fill an array with random ints $ints2 = array(); for ($i = 0; $i < INT_COUNT; $i++){ $ints2[] = rand(0, 255); } // asort the ints asort($ints2); $start = microtime(true); // Do nothing but access each int in the array for ($i = 0; $i < INT_COUNT; $i++){ $ints2[$i]; } $finish = microtime(true); printf("Time taken with asort(): %.5f seconds\n", $finish - $start);
Output for 7.1.0
Time taken with sort(): 0.01655 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.14
Time taken with sort(): -0.01902 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.10
Time taken with sort(): 0.02300 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.9
Time taken with sort(): 0.01950 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.8
Time taken with sort(): 0.01902 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.7
Time taken with sort(): 0.01947 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.6
Time taken with sort(): 0.01929 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.5
Time taken with sort(): 0.02092 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.4
Time taken with sort(): 0.01607 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.3
Time taken with sort(): 0.01988 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.2
Time taken with sort(): 0.01963 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.1
Time taken with sort(): 0.02007 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for 7.0.0
Time taken with sort(): 0.01985 seconds Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/sRQXr on line 31
Process exited with code 255.
Output for hhvm-3.12.0
Time taken with sort(): 0.09270 seconds Time taken with asort(): 0.26389 seconds
Output for hhvm-3.10.0
Time taken with sort(): 0.13729 seconds Time taken with asort(): 0.26416 seconds
Output for 5.3.0 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/sRQXr on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_CONST in /in/sRQXr on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST in /in/sRQXr on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/sRQXr on line 3
Process exited with code 255.