3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set( 'MAX_EXEC_TIME', 120 ); ob_start( ); $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'; ob_end_flush( );
Output for 7.1.7
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0926487445831 seconds and 0 bytes<br /> ++$i took 0.78095316886902 seconds and 0 bytes
Output for 7.1.6
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0366699695587 seconds and 0 bytes<br /> ++$i took 0.75665807723999 seconds and 0 bytes
Output for 7.1.5
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0896098613739 seconds and 0 bytes<br /> ++$i took 0.84513092041016 seconds and 0 bytes
Output for 7.1.4
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 0.97831392288208 seconds and 0 bytes<br /> ++$i took 0.71822905540466 seconds and 0 bytes
Output for 7.1.3
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0732088088989 seconds and 0 bytes<br /> ++$i took 0.81184434890747 seconds and 0 bytes
Output for 7.1.2
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0218806266785 seconds and 0 bytes<br /> ++$i took 0.75853490829468 seconds and 0 bytes
Output for 7.1.1
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0045938491821 seconds and 0 bytes<br /> ++$i took 0.76675415039062 seconds and 0 bytes
Output for 7.1.0
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0081598758698 seconds and 0 bytes<br /> ++$i took 0.76856565475464 seconds and 0 bytes
Output for 7.0.20
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1587710380554 seconds and 0 bytes<br /> ++$i took 0.8639497756958 seconds and 0 bytes
Output for 7.0.19
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0342688560486 seconds and 0 bytes<br /> ++$i took 0.7723662853241 seconds and 0 bytes
Output for 7.0.18
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0708408355713 seconds and 0 bytes<br /> ++$i took 0.77805709838867 seconds and 0 bytes
Output for 7.0.17
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0414674282074 seconds and 0 bytes<br /> ++$i took 0.78068971633911 seconds and 0 bytes
Output for 7.0.16
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.165604352951 seconds and 0 bytes<br /> ++$i took 0.89072799682617 seconds and 0 bytes
Output for 7.0.15
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.145715713501 seconds and 0 bytes<br /> ++$i took 0.90213418006897 seconds and 0 bytes
Output for 7.0.14
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0306191444397 seconds and 0 bytes<br /> ++$i took 0.76104664802551 seconds and 0 bytes
Output for 7.0.13
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0472822189331 seconds and 0 bytes<br /> ++$i took 0.76874303817749 seconds and 0 bytes
Output for 7.0.12
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1165771484375 seconds and 0 bytes<br /> ++$i took 0.88024353981018 seconds and 0 bytes
Output for 7.0.11
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1386137008667 seconds and 0 bytes<br /> ++$i took 0.85886144638062 seconds and 0 bytes
Output for 7.0.10
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0341377258301 seconds and 0 bytes<br /> ++$i took 0.76574873924255 seconds and 0 bytes
Output for 7.0.9
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.054004907608 seconds and 0 bytes<br /> ++$i took 0.78236603736877 seconds and 0 bytes
Output for 7.0.8
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0913252830505 seconds and 0 bytes<br /> ++$i took 0.78684210777283 seconds and 0 bytes
Output for 7.0.7
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0242249965668 seconds and 0 bytes<br /> ++$i took 0.78410887718201 seconds and 0 bytes
Output for 7.0.6
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1056709289551 seconds and 0 bytes<br /> ++$i took 0.87146711349487 seconds and 0 bytes
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.5

Process exited with code 137.
Output for 7.0.4
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0399005413055 seconds and 0 bytes<br /> ++$i took 0.77792191505432 seconds and 0 bytes
Output for 7.0.3
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.1739590167999 seconds and 0 bytes<br /> ++$i took 0.84446692466736 seconds and 0 bytes
Output for 7.0.2
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0850448608398 seconds and 0 bytes<br /> ++$i took 0.81505107879639 seconds and 0 bytes
Output for 7.0.1
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0076727867126 seconds and 0 bytes<br /> ++$i took 0.75744962692261 seconds and 0 bytes
Output for 7.0.0
Notice: Undefined index: time in /in/RfZES on line 27 There were 10 tests conducted, here's the totals<br /><br /> $i++ took 1.0231802463531 seconds and 0 bytes<br /> ++$i took 0.78447937965393 seconds and 0 bytes

preferences:
165.28 ms | 401 KiB | 178 Q