3v4l.org

run code in 200+ php & hhvm versions
<?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 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 19
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 35
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 55
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 74
Branch analysis from position: 80
2 jumps found. (Code = 77) Position 1 = 88, Position 2 = 101
Branch analysis from position: 88
2 jumps found. (Code = 78) Position 1 = 89, Position 2 = 101
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 88
Branch analysis from position: 88
Branch analysis from position: 101
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 101
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 80, Position 2 = 74
Branch analysis from position: 80
Branch analysis from position: 74
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 55
Branch analysis from position: 61
Branch analysis from position: 55
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 35
Branch analysis from position: 42
Branch analysis from position: 35
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 19
Branch analysis from position: 22
Branch analysis from position: 19
filename:       /in/l75kf
function name:  (null)
number of ops:  103
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
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   9     1        ASSIGN                                                   !0, 100000
  11     2        INIT_FCALL                                               'str_repeat'
         3        SEND_VAL                                                 'a'
         4        SEND_VAL                                                 512
         5        DO_ICALL                                         $10     
         6        ASSIGN                                                   !1, $10
  14     7        ASSIGN                                                   !2, <array>
  20     8        NOP                                                      
  25     9        NOP                                                      
  31    10        NEW                                              $15     :0
        11        DO_FCALL                                      0          
        12        ASSIGN                                                   !3, $15
  33    13        INIT_FCALL                                               'microtime'
        14        SEND_VAL                                                 <true>
        15        DO_ICALL                                         $18     
        16        ASSIGN                                                   !4, $18
  34    17        ASSIGN                                                   !5, 0
        18      > JMP                                                      ->20
        19    >   PRE_INC                                                  !5
        20    >   IS_SMALLER                                       ~22     !5, !0
        21      > JMPNZ                                                    ~22, ->19
  35    22    >   INIT_FCALL                                               'microtime'
        23        SEND_VAL                                                 <true>
        24        DO_ICALL                                         $23     
        25        SUB                                              ~24     $23, !4
        26        ASSIGN                                                   !6, ~24
  36    27        ASSIGN_ADD                                  147          !2, 'loop'
        28        OP_DATA                                                  !6
  38    29        INIT_FCALL                                               'microtime'
        30        SEND_VAL                                                 <true>
        31        DO_ICALL                                         $27     
        32        ASSIGN                                                   !4, $27
  39    33        ASSIGN                                                   !5, 0
        34      > JMP                                                      ->40
  40    35    >   INIT_FCALL                                               'strcmp'
        36        SEND_VAR                                                 !1
        37        SEND_VAR                                                 !1
        38        DO_ICALL                                                 
  39    39        PRE_INC                                                  !5
        40    >   IS_SMALLER                                       ~32     !5, !0
        41      > JMPNZ                                                    ~32, ->35
  42    42    >   INIT_FCALL                                               'microtime'
        43        SEND_VAL                                                 <true>
        44        DO_ICALL                                         $33     
        45        SUB                                              ~34     $33, !4
        46        ASSIGN                                                   !6, ~34
  43    47        ASSIGN_ADD                                  147          !2, 'direct'
        48        OP_DATA                                                  !6
  45    49        INIT_FCALL                                               'microtime'
        50        SEND_VAL                                                 <true>
        51        DO_ICALL                                         $37     
        52        ASSIGN                                                   !4, $37
  46    53        ASSIGN                                                   !5, 0
        54      > JMP                                                      ->59
  47    55    >   INIT_STATIC_METHOD_CALL                                  'Os', 'strcmp'
        56        SEND_VAR                                                 !1
        57        DO_FCALL                                      0          
  46    58        PRE_INC                                                  !5
        59    >   IS_SMALLER                                       ~42     !5, !0
        60      > JMPNZ                                                    ~42, ->55
  49    61    >   INIT_FCALL                                               'microtime'
        62        SEND_VAL                                                 <true>
        63        DO_ICALL                                         $43     
        64        SUB                                              ~44     $43, !4
        65        ASSIGN                                                   !6, ~44
  50    66        ASSIGN_ADD                                  147          !2, 'static'
        67        OP_DATA                                                  !6
  52    68        INIT_FCALL                                               'microtime'
        69        SEND_VAL                                                 <true>
        70        DO_ICALL                                         $47     
        71        ASSIGN                                                   !4, $47
  53    72        ASSIGN                                                   !5, 0
        73      > JMP                                                      ->78
  54    74    >   INIT_METHOD_CALL                                         !3, 'strcmp'
        75        SEND_VAR_EX                                              !1
        76        DO_FCALL                                      0          
  53    77        PRE_INC                                                  !5
        78    >   IS_SMALLER                                       ~52     !5, !0
        79      > JMPNZ                                                    ~52, ->74
  56    80    >   INIT_FCALL                                               'microtime'
        81        SEND_VAL                                                 <true>
        82        DO_ICALL                                         $53     
        83        SUB                                              ~54     $53, !4
        84        ASSIGN                                                   !6, ~54
  57    85        ASSIGN_ADD                                  147          !2, 'object'
        86        OP_DATA                                                  !6
  60    87      > FE_RESET_R                                       $57     !2, ->101
        88    > > FE_FETCH_R                                       ~58     $57, !7, ->101
        89    >   ASSIGN                                                   !8, ~58
  61    90        INIT_FCALL                                               'report'
        91        SEND_VAR                                                 !8
        92        DIV                                              ~60     !7, !0
        93        MUL                                              ~61     ~60, 1000
        94        SEND_VAL                                                 ~61
        95        FETCH_DIM_R                                      $62     !2, 'loop'
        96        DIV                                              ~63     $62, !0
        97        MUL                                              ~64     ~63, 1000
        98        SEND_VAL                                                 ~64
        99        DO_FCALL                                      0          
       100      > JMP                                                      ->88
       101    >   FE_FREE                                                  $57
  62   102      > 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 7.3.0