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

Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 37
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 37
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 35
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 35
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 35
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/EZX84
function name:  (null)
number of ops:  39
compiled vars:  !0 = $num, !1 = $inputs, !2 = $arrays, !3 = $arr, !4 = $arrDesc, !5 = $input
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                       !0, 1000000
   31     1        ASSIGN                                                       !1, <array>
   32     2        ASSIGN                                                       !2, <array>
   34     3      > FE_RESET_R                                           $9      !2, ->37
          4    > > FE_FETCH_R                                           ~10     $9, !3, ->37
          5    >   ASSIGN                                                       !4, ~10
   35     6      > FE_RESET_R                                           $12     !1, ->35
          7    > > FE_FETCH_R                                                   $12, !5, ->35
   36     8    >   ROPE_INIT                                         4  ~14     'Running+with+array%3D'
          9        ROPE_ADD                                          1  ~14     ~14, !4
         10        ROPE_ADD                                          2  ~14     ~14, '+and+input+'
         11        ROPE_END                                          3  ~13     ~14, !5
         12        ECHO                                                         ~13
         13        ECHO                                                         '%0A'
   37    14        ECHO                                                         'Check%3A+'
         15        INIT_FCALL                                                   'testcheck'
         16        SEND_VAR                                                     !0
         17        SEND_VAR                                                     !3
         18        SEND_VAR                                                     !5
         19        DO_FCALL                                          0  $16     
         20        DIV                                                  ~17     $16, 1000000
         21        ECHO                                                         ~17
         22        ECHO                                                         '+ms'
         23        ECHO                                                         '%0A'
   38    24        ECHO                                                         'Silence%3A+'
         25        INIT_FCALL                                                   'testsilence'
         26        SEND_VAR                                                     !0
         27        SEND_VAR                                                     !3
         28        SEND_VAR                                                     !5
         29        DO_FCALL                                          0  $18     
         30        DIV                                                  ~19     $18, 1000000
         31        ECHO                                                         ~19
         32        ECHO                                                         '+ms'
         33        ECHO                                                         '%0A'
   35    34      > JMP                                                          ->7
         35    >   FE_FREE                                                      $12
   34    36      > JMP                                                          ->4
         37    >   FE_FREE                                                      $9
   40    38      > RETURN                                                       1

Function testcheck:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
Branch analysis from position: 13
filename:       /in/EZX84
function name:  testCheck
number of ops:  28
compiled vars:  !0 = $numRounds, !1 = $testArr, !2 = $input, !3 = $start, !4 = $i, !5 = $_
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
    4     3        INIT_FCALL                                                   'hrtime'
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !3, $6
    5     7        ASSIGN                                                       !4, 0
          8      > JMP                                                          ->20
    6     9    >   TYPE_CHECK                                       32          !2
         10      > JMPZ                                                         ~9, ->13
    7    11    >   CAST                                              4  ~10     !2
         12        ASSIGN                                                       !2, ~10
    9    13    >   ISSET_ISEMPTY_DIM_OBJ                             0          !1, !2
         14      > JMPZ                                                         ~12, ->18
   10    15    >   FETCH_DIM_R                                          ~13     !1, !2
         16        ASSIGN                                                       !5, ~13
    9    17      > JMP                                                          ->19
   12    18    >   ASSIGN                                                       !5, 42
    5    19    >   PRE_INC                                                      !4
         20    >   IS_SMALLER                                                   !4, !0
         21      > JMPNZ                                                        ~17, ->9
   15    22    >   INIT_FCALL                                                   'hrtime'
         23        SEND_VAL                                                     <true>
         24        DO_ICALL                                             $18     
         25        SUB                                                  ~19     $18, !3
         26      > RETURN                                                       ~19
   16    27*     > RETURN                                                       null

End of function testcheck

Function testsilence:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/EZX84
function name:  testSilence
number of ops:  28
compiled vars:  !0 = $numRounds, !1 = $testArr, !2 = $input, !3 = $start, !4 = $i, !5 = $_
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   19     3        INIT_FCALL                                                   'hrtime'
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !3, $6
   20     7        ASSIGN                                                       !4, 0
          8      > JMP                                                          ->20
   21     9    >   BEGIN_SILENCE                                        ~9      
         10        ISSET_ISEMPTY_DIM_OBJ                             0  ~10     !1, !2
         11        END_SILENCE                                                  ~9
         12      > JMPZ                                                         ~10, ->18
   22    13    >   BEGIN_SILENCE                                        ~11     
         14        FETCH_DIM_R                                          ~12     !1, !2
         15        END_SILENCE                                                  ~11
         16        ASSIGN                                                       !5, ~12
   21    17      > JMP                                                          ->19
   24    18    >   ASSIGN                                                       !5, 42
   20    19    >   PRE_INC                                                      !4
         20    >   IS_SMALLER                                                   !4, !0
         21      > JMPNZ                                                        ~16, ->9
   27    22    >   INIT_FCALL                                                   'hrtime'
         23        SEND_VAL                                                     <true>
         24        DO_ICALL                                             $17     
         25        SUB                                                  ~18     $17, !3
         26      > RETURN                                                       ~18
   28    27*     > RETURN                                                       null

End of function testsilence

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178.17 ms | 1278 KiB | 12 Q