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; } $start1 = microtime(1); for ($i = 1; $i < 10000; $i++) { test1(); } $start -= microtime(1); echo "test1: $start1"; $start2 = microtime(1); for ($i = 1; $i < 10000; $i++) { test2(); } $start2 -= microtime(1); echo "\ntest2: $start2"; if ($start1 < $start2) { $perc = round(($start2 / $start1) * 100,2)-100; echo "Test1 is $perc faster than Test2"; } if ($start2 < $start2) { $perc = round(($start1 / $start2) * 100,2)-100; echo "Test2 is $perc faster than Test1"; }
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
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 50
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 64
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
Branch analysis from position: 50
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/OKBE3
function name:  (null)
number of ops:  65
compiled vars:  !0 = $start1, !1 = $i, !2 = $start, !3 = $start2, !4 = $perc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 1
          2        DO_ICALL                                         $5      
          3        ASSIGN                                                   !0, $5
   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                                                    ~10, ->6
   31    11    >   INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 1
         13        DO_ICALL                                         $11     
         14        ASSIGN_OP                                     2          !2, $11
   32    15        NOP                                                      
         16        FAST_CONCAT                                      ~13     'test1%3A+', !0
         17        ECHO                                                     ~13
   35    18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $14     
         21        ASSIGN                                                   !3, $14
   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                                                    ~19, ->24
   39    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 1
         31        DO_ICALL                                         $20     
         32        ASSIGN_OP                                     2          !3, $20
   40    33        NOP                                                      
         34        FAST_CONCAT                                      ~22     '%0Atest2%3A+', !3
         35        ECHO                                                     ~22
   43    36        IS_SMALLER                                               !0, !3
         37      > JMPZ                                                     ~23, ->50
   44    38    >   INIT_FCALL                                               'round'
         39        DIV                                              ~24     !3, !0
         40        MUL                                              ~25     ~24, 100
         41        SEND_VAL                                                 ~25
         42        SEND_VAL                                                 2
         43        DO_ICALL                                         $26     
         44        SUB                                              ~27     $26, 100
         45        ASSIGN                                                   !4, ~27
   45    46        ROPE_INIT                                     3  ~30     'Test1+is+'
         47        ROPE_ADD                                      1  ~30     ~30, !4
         48        ROPE_END                                      2  ~29     ~30, '+faster+than+Test2'
         49        ECHO                                                     ~29
   49    50    >   IS_SMALLER                                               !3, !3
         51      > JMPZ                                                     ~32, ->64
   50    52    >   INIT_FCALL                                               'round'
         53        DIV                                              ~33     !0, !3
         54        MUL                                              ~34     ~33, 100
         55        SEND_VAL                                                 ~34
         56        SEND_VAL                                                 2
         57        DO_ICALL                                         $35     
         58        SUB                                              ~36     $35, 100
         59        ASSIGN                                                   !4, ~36
   51    60        ROPE_INIT                                     3  ~39     'Test2+is+'
         61        ROPE_ADD                                      1  ~39     ~39, !4
         62        ROPE_END                                      2  ~38     ~39, '+faster+than+Test1'
         63        ECHO                                                     ~38
   52    64    > > 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/OKBE3
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/OKBE3
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:
141.51 ms | 1404 KiB | 21 Q