3v4l.org

run code in 300+ PHP versions simultaneously
<?php function report($name, $time, $base) { printf("%-12s: %.8fms", $name, $time); printf(", %.1f%%", (($time - $base)/$base)*100); echo PHP_EOL; } $iterations = 100000; $a = str_repeat('a', 2<<8); $times = array( "loop" => 0, "direct" => 0, "static" => 0, "object" => 0 ); class Os { public static function strcmp($a) { strcmp($a, $a); } } class Om { public function strcmp($a) { strcmp($a, $a); } } $o = new Om(); $start = microtime(true); for ($x=0; $x<$iterations; ++$x) {} $end = microtime(true) - $start; $times["loop"]+= $end; $start = microtime(true); for ($x=0; $x<$iterations; ++$x) { strcmp($a, $a); } $end = microtime(true) - $start; $times["direct"]+= $end; $start = microtime(true); for ($x=0; $x<$iterations; ++$x) { Os::strcmp($a); } $end = microtime(true) - $start; $times["static"]+= $end; $start = microtime(true); for ($x=0; $x<$iterations; ++$x) { $o->strcmp($a); } $end = microtime(true) - $start; $times["object"]+= $end; foreach ($times as $name => $time) { report($name, ($time/$iterations)*1000, ($times['loop']/$iterations)*1000); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 16
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 52
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 71
Branch analysis from position: 77
2 jumps found. (Code = 77) Position 1 = 85, Position 2 = 98
Branch analysis from position: 85
2 jumps found. (Code = 78) Position 1 = 86, Position 2 = 98
Branch analysis from position: 86
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 98
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 98
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 71
Branch analysis from position: 77
Branch analysis from position: 71
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 52
Branch analysis from position: 58
Branch analysis from position: 52
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 32
Branch analysis from position: 39
Branch analysis from position: 32
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 16
Branch analysis from position: 19
Branch analysis from position: 16
filename:       /in/l75kf
function name:  (null)
number of ops:  100
compiled vars:  !0 = $iterations, !1 = $a, !2 = $times, !3 = $o, !4 = $start, !5 = $x, !6 = $end, !7 = $time, !8 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, 100000
   11     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 'a'
          3        SEND_VAL                                                 512
          4        DO_ICALL                                         $10     
          5        ASSIGN                                                   !1, $10
   13     6        ASSIGN                                                   !2, <array>
   31     7        NEW                                              $13     'Om'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !3, $13
   33    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $16     
         13        ASSIGN                                                   !4, $16
   34    14        ASSIGN                                                   !5, 0
         15      > JMP                                                      ->17
         16    >   PRE_INC                                                  !5
         17    >   IS_SMALLER                                               !5, !0
         18      > JMPNZ                                                    ~20, ->16
   35    19    >   INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $21     
         22        SUB                                              ~22     $21, !4
         23        ASSIGN                                                   !6, ~22
   36    24        ASSIGN_DIM_OP                +=               1          !2, 'loop'
         25        OP_DATA                                                  !6
   38    26        INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $25     
         29        ASSIGN                                                   !4, $25
   39    30        ASSIGN                                                   !5, 0
         31      > JMP                                                      ->37
   40    32    >   INIT_FCALL                                               'strcmp'
         33        SEND_VAR                                                 !1
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
   39    36        PRE_INC                                                  !5
         37    >   IS_SMALLER                                               !5, !0
         38      > JMPNZ                                                    ~30, ->32
   42    39    >   INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $31     
         42        SUB                                              ~32     $31, !4
         43        ASSIGN                                                   !6, ~32
   43    44        ASSIGN_DIM_OP                +=               1          !2, 'direct'
         45        OP_DATA                                                  !6
   45    46        INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $35     
         49        ASSIGN                                                   !4, $35
   46    50        ASSIGN                                                   !5, 0
         51      > JMP                                                      ->56
   47    52    >   INIT_STATIC_METHOD_CALL                                  'Os', 'strcmp'
         53        SEND_VAR                                                 !1
         54        DO_FCALL                                      0          
   46    55        PRE_INC                                                  !5
         56    >   IS_SMALLER                                               !5, !0
         57      > JMPNZ                                                    ~40, ->52
   49    58    >   INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $41     
         61        SUB                                              ~42     $41, !4
         62        ASSIGN                                                   !6, ~42
   50    63        ASSIGN_DIM_OP                +=               1          !2, 'static'
         64        OP_DATA                                                  !6
   52    65        INIT_FCALL                                               'microtime'
         66        SEND_VAL                                                 <true>
         67        DO_ICALL                                         $45     
         68        ASSIGN                                                   !4, $45
   53    69        ASSIGN                                                   !5, 0
         70      > JMP                                                      ->75
   54    71    >   INIT_METHOD_CALL                                         !3, 'strcmp'
         72        SEND_VAR_EX                                              !1
         73        DO_FCALL                                      0          
   53    74        PRE_INC                                                  !5
         75    >   IS_SMALLER                                               !5, !0
         76      > JMPNZ                                                    ~50, ->71
   56    77    >   INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $51     
         80        SUB                                              ~52     $51, !4
         81        ASSIGN                                                   !6, ~52
   57    82        ASSIGN_DIM_OP                +=               1          !2, 'object'
         83        OP_DATA                                                  !6
   60    84      > FE_RESET_R                                       $55     !2, ->98
         85    > > FE_FETCH_R                                       ~56     $55, !7, ->98
         86    >   ASSIGN                                                   !8, ~56
   61    87        INIT_FCALL                                               'report'
         88        SEND_VAR                                                 !8
         89        DIV                                              ~58     !7, !0
         90        MUL                                              ~59     ~58, 1000
         91        SEND_VAL                                                 ~59
         92        FETCH_DIM_R                                      ~60     !2, 'loop'
         93        DIV                                              ~61     ~60, !0
         94        MUL                                              ~62     ~61, 1000
         95        SEND_VAL                                                 ~62
         96        DO_FCALL                                      0          
   60    97      > JMP                                                      ->85
         98    >   FE_FREE                                                  $55
   62    99      > RETURN                                                   1

Function report:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l75kf
function name:  report
number of ops:  17
compiled vars:  !0 = $name, !1 = $time, !2 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL                                               'printf'
          4        SEND_VAL                                                 '%25-12s%3A+%25.8fms'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
    5     8        INIT_FCALL                                               'printf'
          9        SEND_VAL                                                 '%2C+%25.1f%25%25'
         10        SUB                                              ~4      !1, !2
         11        DIV                                              ~5      ~4, !2
         12        MUL                                              ~6      ~5, 100
         13        SEND_VAL                                                 ~6
         14        DO_ICALL                                                 
    6    15        ECHO                                                     '%0A'
    7    16      > RETURN                                                   null

End of function report

Class Os:
Function strcmp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l75kf
function name:  strcmp
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'strcmp'
          2        SEND_VAR                                                 !0
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   23     5      > RETURN                                                   null

End of function strcmp

End of class Os.

Class Om:
Function strcmp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l75kf
function name:  strcmp
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   27     1        INIT_FCALL                                               'strcmp'
          2        SEND_VAR                                                 !0
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   28     5      > RETURN                                                   null

End of function strcmp

End of class Om.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.78 ms | 1411 KiB | 22 Q