3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test1() { $str = 'derp'; if ($str != 'files' && $str != 'something' && $str != 'Derrr') { return; } return; } function test2() { $str = 'derp'; switch ($str) { case 'files': case 'something': case 'Derrr': break; default: return; } return; } $start = microtime(1); for ($i = 1; $i < 10000; $i++) { test1(); } $start -= microtime(1); echo "test1: $start"; $start = microtime(1); for ($i = 1; $i < 10000; $i++) { test2(); } $start -= microtime(1); echo "test2: $start";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 6
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 24
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 24
Branch analysis from position: 29
Branch analysis from position: 24
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 6
Branch analysis from position: 11
Branch analysis from position: 6
filename:       /in/iHADf
function name:  (null)
number of ops:  37
compiled vars:  !0 = $start, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 1
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   28     4        ASSIGN                                                   !1, 1
          5      > JMP                                                      ->9
   29     6    >   INIT_FCALL                                               'test1'
          7        DO_FCALL                                      0          
   28     8        PRE_INC                                                  !1
          9    >   IS_SMALLER                                               !1, 10000
         10      > JMPNZ                                                    ~7, ->6
   31    11    >   INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $8      
         14        ASSIGN_OP                                     2          !0, $8
   32    15        NOP                                                      
         16        FAST_CONCAT                                      ~10     'test1%3A+', !0
         17        ECHO                                                     ~10
   35    18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !0, $11
   36    22        ASSIGN                                                   !1, 1
         23      > JMP                                                      ->27
   37    24    >   INIT_FCALL                                               'test2'
         25        DO_FCALL                                      0          
   36    26        PRE_INC                                                  !1
         27    >   IS_SMALLER                                               !1, 10000
         28      > JMPNZ                                                    ~16, ->24
   39    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 1
         31        DO_ICALL                                         $17     
         32        ASSIGN_OP                                     2          !0, $17
   40    33        NOP                                                      
         34        FAST_CONCAT                                      ~19     'test2%3A+', !0
         35        ECHO                                                     ~19
         36      > RETURN                                                   1

Function test1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 5
filename:       /in/iHADf
function name:  test1
number of ops:  12
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, 'derp'
    6     1        IS_NOT_EQUAL                                     ~2      !0, 'files'
          2      > JMPZ_EX                                          ~2      ~2, ->5
          3    >   IS_NOT_EQUAL                                     ~3      !0, 'something'
          4        BOOL                                             ~2      ~3
          5    > > JMPZ_EX                                          ~2      ~2, ->8
          6    >   IS_NOT_EQUAL                                     ~4      !0, 'Derrr'
          7        BOOL                                             ~2      ~4
          8    > > JMPZ                                                     ~2, ->10
    7     9    > > RETURN                                                   null
    9    10    > > RETURN                                                   null
   10    11*     > RETURN                                                   null

End of function test1

Function test2:
Finding entry points
Branch analysis from position: 0
5 jumps found. (Code = 188) Position 1 = 9, Position 2 = 9, Position 3 = 9, Position 4 = 10, Position 5 = 2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
Branch analysis from position: 9
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 9
Branch analysis from position: 9
Branch analysis from position: 9
filename:       /in/iHADf
function name:  test2
number of ops:  13
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 'derp'
   16     1      > SWITCH_STRING                                            !0, [ 'files':->9, 'something':->9, 'Derrr':->9, ], ->10
   17     2    >   IS_EQUAL                                                 !0, 'files'
          3      > JMPNZ                                                    ~2, ->9
   18     4    >   IS_EQUAL                                                 !0, 'something'
          5      > JMPNZ                                                    ~2, ->9
   19     6    >   IS_EQUAL                                                 !0, 'Derrr'
          7      > JMPNZ                                                    ~2, ->9
          8    > > JMP                                                      ->10
   20     9    > > JMP                                                      ->11
   22    10    > > RETURN                                                   null
   24    11    > > RETURN                                                   null
   25    12*     > RETURN                                                   null

End of function test2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.03 ms | 1404 KiB | 19 Q