3v4l.org

run code in 500+ PHP versions simultaneously
<?php function testCheck( int $numRounds, array $testArr, $input ) { $start = hrtime( true ); for ( $i = 0; $i < $numRounds; $i++ ) { if ( is_float( $input ) ) { $input = (int)$input; } if ( isset( $testArr[$input] ) ) { $_ = $testArr[$input]; } else { $_ = 42; } } return hrtime( true ) - $start; } function testSilence( int $numRounds, array $testArr, $input ) { $start = hrtime( true ); for ( $i = 0; $i < $numRounds; $i++ ) { if ( @isset( $testArr[$input] ) ) { $_ = @$testArr[$input]; } else { $_ = 42; } } return hrtime( true ) - $start; } $num = 1000000; $inputs = [ 1, true, 'foobar', 1.3 ]; $arrays = [ 'unset' => [], 'set' => [ 1 => 42 ] ]; foreach ( $arrays as $arrDesc => $arr ) { foreach ( $inputs as $input ) { echo "Running with array=$arrDesc and input $input", PHP_EOL; echo "Check: ", testCheck( $num, $arr, $input ) / 10**6, " ms", PHP_EOL; echo "Silence: ", testSilence( $num, $arr, $input ) / 10**6, " ms", PHP_EOL; } }

Abusive script

This script was stopped while abusing our resources

Output for master
Running with array=unset and input 1 Check: 9.692396 ms Silence: 16.541595 ms Running with array=unset and input 1 Check: 11.250425 ms Silence: 16.755115 ms Running with array=unset and input foobar Check: 10.322 ms Silence: 15.807714 ms Running with array=unset and input 1.3 Check: 10.32717 ms Silence: 297.270617 ms Running with array=set and input 1 Check: 16.905491 ms Silence: 28.399301 ms Running with array=set and input 1 Check: 19.542999 ms Silence: 31.78304 ms Running with array=set and input foobar Check: 11.073709 ms Silence: 16.29205 ms Running with array=set and input 1.3 Check: 17.718111 ms Silence: 656.439821 ms

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
28.64 ms | 1948 KiB | 8 Q