3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set( 'MAX_EXEC_TIME', 120 ); $num_tests = 10; $startFirst = $startSecond = $endFirst = $endSecond = $startFirstMemory = $endFirstMemory = $startSecondMemory = $endSecondMemory = $someVal = 0; $times = array( '$i++' => array( 'time' => 0, 'memory' => 0 ), '++$i' => array( 'total' => 0, 'memory' => 0 ) ); for( $j = 0; $j < $num_tests; ++$j ) { for( $i = 0, $startFirstMemory = memory_get_usage( ), $startFirst = microtime( true ); $i < 10000000; $i++ ){ $someval = 2; } $endFirstMemory = memory_get_usage( ); $endFirst = microtime( true ); for( $i = 0, $startSecondMemory = memory_get_usage( ), $startSecond = microtime( true ); $i < 10000000; ++$i ){ $someval = 2; } $endSecondMemory = memory_get_usage( ); $endSecond = microtime( true ); $times[ '$i++' ][ $j ] = array( 'startTime' => $startFirst, 'endTime' => $endFirst, 'startMemory' => $startFirstMemory, 'endMemory' => $endFirstMemory ); $times[ '++$i' ][ $j ] = array( 'startTime' => $startSecond, 'endTime' => $endSecond, 'startMemory' => $startSecondMemory, 'endMemory' => $endSecondMemory ); } for( $i = 0; $i < $num_tests; ++$i ) { $times[ '$i++' ][ 'time' ] += ( $times[ '$i++' ][ $i ][ 'endTime' ] - $times[ '$i++' ][ $i ][ 'startTime' ] ); $times[ '++$i' ][ 'time' ] += ( $times[ '++$i' ][ $i ][ 'endTime' ] - $times[ '++$i' ][ $i ][ 'startTime' ] ); $times[ '$i++' ][ 'memory' ] += ( $times[ '$i++' ][ $i ][ 'endMemory' ] - $times[ '$i++' ][ $i ][ 'startMemory' ] ); $times[ '++$i' ][ 'memory' ] += ( $times[ '++$i' ][ $i ][ 'endMemory' ] - $times[ '++$i' ][ $i ][ 'startMemory' ] ); } echo 'There were ' . $num_tests . ' tests conducted, here\'s the totals<br /><br /> $i++ took ' . $times[ '$i++' ][ 'time' ] . ' seconds and ' . $times[ '$i++' ][ 'memory' ] . ' bytes<br /> ++$i took ' . $times[ '++$i' ][ 'time' ] . ' seconds and ' . $times[ '++$i' ][ 'memory' ] . ' bytes';
Output for 7.2.0
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0164043903351 seconds and 0 bytes<br /> ++$i took 0.80487489700317 seconds and 0 bytes
Output for 7.1.7
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1010231971741 seconds and 0 bytes<br /> ++$i took 0.79013299942017 seconds and 0 bytes
Output for 7.1.6
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0424115657806 seconds and 0 bytes<br /> ++$i took 0.71304607391357 seconds and 0 bytes
Output for 7.1.5
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.99727463722229 seconds and 0 bytes<br /> ++$i took 0.75436735153198 seconds and 0 bytes
Output for 7.1.0
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took -0.5360848903656 seconds and 0 bytes<br /> ++$i took 1.2227869033813 seconds and 0 bytes
Output for 7.0.20
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.401487827301 seconds and 0 bytes<br /> ++$i took 1.0413281917572 seconds and 0 bytes
Output for 7.0.14
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0614833831787 seconds and 0 bytes<br /> ++$i took 0.73080062866211 seconds and 0 bytes
Output for 7.0.10
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.95521569252014 seconds and 0 bytes<br /> ++$i took 0.6720654964447 seconds and 0 bytes
Output for 7.0.9
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.90372967720032 seconds and 0 bytes<br /> ++$i took 0.68338894844055 seconds and 0 bytes
Output for 7.0.8
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.92919397354126 seconds and 0 bytes<br /> ++$i took 0.68685984611511 seconds and 0 bytes
Output for 7.0.7
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.93744683265686 seconds and 0 bytes<br /> ++$i took 0.68531680107117 seconds and 0 bytes
Output for 7.0.6
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.96785879135132 seconds and 0 bytes<br /> ++$i took 0.751145362854 seconds and 0 bytes
Output for 7.0.5
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.91391491889954 seconds and 0 bytes<br /> ++$i took 0.70301461219788 seconds and 0 bytes
Output for 7.0.4
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.98513793945312 seconds and 0 bytes<br /> ++$i took 0.77338910102844 seconds and 0 bytes
Output for 7.0.3
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.9465663433075 seconds and 0 bytes<br /> ++$i took 0.66437101364136 seconds and 0 bytes
Output for 7.0.2
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.89194512367249 seconds and 0 bytes<br /> ++$i took 0.63395619392395 seconds and 0 bytes
Output for 7.0.1
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.91677761077881 seconds and 0 bytes<br /> ++$i took 0.67504501342773 seconds and 0 bytes
Output for 7.0.0
Notice: Undefined index: time in /in/5aNS1 on line 26 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.92661237716675 seconds and 0 bytes<br /> ++$i took 0.7846622467041 seconds and 0 bytes
Output for 5.2.1 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28

Process exited with code 137.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/5aNS1 on line 11
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_usage() in /in/5aNS1 on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: memory_get_usage() in /in/5aNS1 on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_usage() in /in/5aNS1 on line 11

preferences:
181.28 ms | 401 KiB | 216 Q