3v4l.org

run code in 300+ PHP versions simultaneously
<?php function report($name, $time) { static $last = null; printf("%-12s: %.8fms", $name, $time); if (null !== $last) { printf(", %.1f%%", (($time - $last)/$last)*100); } echo PHP_EOL; $last = $time; } $iterations = 100000; $a = str_repeat('a', 2<<8); $times = array( "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++) { 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); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 36
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
2 jumps found. (Code = 77) Position 1 = 69, Position 2 = 78
Branch analysis from position: 69
2 jumps found. (Code = 78) Position 1 = 70, Position 2 = 78
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
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: 36
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 36
Branch analysis from position: 42
Branch analysis from position: 36
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
Branch analysis from position: 16
filename:       /in/eJK07
function name:  (null)
number of ops:  80
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
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 100000
   15     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 'a'
          3        SEND_VAL                                                 512
          4        DO_ICALL                                         $10     
          5        ASSIGN                                                   !1, $10
   17     6        ASSIGN                                                   !2, <array>
   34     7        NEW                                              $13     'Om'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !3, $13
   36    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $16     
         13        ASSIGN                                                   !4, $16
   37    14        ASSIGN                                                   !5, 0
         15      > JMP                                                      ->21
   38    16    >   INIT_FCALL                                               'strcmp'
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   37    20        PRE_INC                                                  !5
         21    >   IS_SMALLER                                               !5, !0
         22      > JMPNZ                                                    ~21, ->16
   40    23    >   INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $22     
         26        SUB                                              ~23     $22, !4
         27        ASSIGN                                                   !6, ~23
   41    28        ASSIGN_DIM_OP                +=               1          !2, 'direct'
         29        OP_DATA                                                  !6
   43    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $26     
         33        ASSIGN                                                   !4, $26
   44    34        ASSIGN                                                   !5, 0
         35      > JMP                                                      ->40
   45    36    >   INIT_STATIC_METHOD_CALL                                  'Os', 'strcmp'
         37        SEND_VAR                                                 !1
         38        DO_FCALL                                      0          
   44    39        PRE_INC                                                  !5
         40    >   IS_SMALLER                                               !5, !0
         41      > JMPNZ                                                    ~31, ->36
   47    42    >   INIT_FCALL                                               'microtime'
         43        SEND_VAL                                                 <true>
         44        DO_ICALL                                         $32     
         45        SUB                                              ~33     $32, !4
         46        ASSIGN                                                   !6, ~33
   48    47        ASSIGN_DIM_OP                +=               1          !2, 'static'
         48        OP_DATA                                                  !6
   50    49        INIT_FCALL                                               'microtime'
         50        SEND_VAL                                                 <true>
         51        DO_ICALL                                         $36     
         52        ASSIGN                                                   !4, $36
   51    53        ASSIGN                                                   !5, 0
         54      > JMP                                                      ->59
   52    55    >   INIT_METHOD_CALL                                         !3, 'strcmp'
         56        SEND_VAR_EX                                              !1
         57        DO_FCALL                                      0          
   51    58        PRE_INC                                                  !5
         59    >   IS_SMALLER                                               !5, !0
         60      > JMPNZ                                                    ~41, ->55
   54    61    >   INIT_FCALL                                               'microtime'
         62        SEND_VAL                                                 <true>
         63        DO_ICALL                                         $42     
         64        SUB                                              ~43     $42, !4
         65        ASSIGN                                                   !6, ~43
   55    66        ASSIGN_DIM_OP                +=               1          !2, 'object'
         67        OP_DATA                                                  !6
   58    68      > FE_RESET_R                                       $46     !2, ->78
         69    > > FE_FETCH_R                                       ~47     $46, !7, ->78
         70    >   ASSIGN                                                   !8, ~47
   59    71        INIT_FCALL                                               'report'
         72        SEND_VAR                                                 !8
         73        DIV                                              ~49     !7, !0
         74        MUL                                              ~50     ~49, 1000
         75        SEND_VAL                                                 ~50
         76        DO_FCALL                                      0          
   58    77      > JMP                                                      ->69
         78    >   FE_FREE                                                  $46
   60    79      > RETURN                                                   1

Function report:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/eJK07
function name:  report
number of ops:  20
compiled vars:  !0 = $name, !1 = $time, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        BIND_STATIC                                              !2
    5     3        INIT_FCALL                                               'printf'
          4        SEND_VAL                                                 '%25-12s%3A+%25.8fms'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
    6     8        TYPE_CHECK                                  1020          !2
          9      > JMPZ                                                     ~4, ->17
    7    10    >   INIT_FCALL                                               'printf'
         11        SEND_VAL                                                 '%2C+%25.1f%25%25'
         12        SUB                                              ~5      !1, !2
         13        DIV                                              ~6      ~5, !2
         14        MUL                                              ~7      ~6, 100
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                                 
    9    17    >   ECHO                                                     '%0A'
   10    18        ASSIGN                                                   !2, !1
   11    19      > 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/eJK07
function name:  strcmp
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'strcmp'
          2        SEND_VAR                                                 !0
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   26     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/eJK07
function name:  strcmp
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        INIT_FCALL                                               'strcmp'
          2        SEND_VAR                                                 !0
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   31     5      > RETURN                                                   null

End of function strcmp

End of class Om.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.01 ms | 1016 KiB | 18 Q