3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { return 1234; } class Foo { public static function asdf() { return 1234; } } $iterations = 1000000; $process = foo(); $process = Foo::asdf(); // Old $a = microtime( true ); for ( $i = 0; $i < $iterations; $i++ ) { $process = foo(); } $b = microtime( true ); $delta1 = $b - $a; // New $x = microtime( true ); for ( $j = 0; $j < $iterations; $j++ ) { $process = Foo::asdf(); } $y = microtime( true ); $delta2 = $y - $x; $percentage = $delta2 / $delta1 * 100; if ( $delta2 < $delta1 ) { printf( 'static method is %.2f%% faster', $percentage ); } else { printf( 'function call is %.2f%% faster', $percentage ); }
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 = 13
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 53
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
Branch analysis from position: 31
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 13
Branch analysis from position: 19
Branch analysis from position: 13
filename:       /in/A7Blr
function name:  (null)
number of ops:  58
compiled vars:  !0 = $iterations, !1 = $process, !2 = $a, !3 = $i, !4 = $b, !5 = $delta1, !6 = $x, !7 = $j, !8 = $y, !9 = $delta2, !10 = $percentage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                   !0, 1000000
   14     1        INIT_FCALL                                               'foo'
          2        DO_FCALL                                      0  $12     
          3        ASSIGN                                                   !1, $12
   15     4        INIT_STATIC_METHOD_CALL                                  'Foo', 'asdf'
          5        DO_FCALL                                      0  $14     
          6        ASSIGN                                                   !1, $14
   18     7        INIT_FCALL                                               'microtime'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $16     
         10        ASSIGN                                                   !2, $16
   19    11        ASSIGN                                                   !3, 0
         12      > JMP                                                      ->17
   20    13    >   INIT_FCALL                                               'foo'
         14        DO_FCALL                                      0  $19     
         15        ASSIGN                                                   !1, $19
   19    16        PRE_INC                                                  !3
         17    >   IS_SMALLER                                               !3, !0
         18      > JMPNZ                                                    ~22, ->13
   22    19    >   INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $23     
         22        ASSIGN                                                   !4, $23
   23    23        SUB                                              ~25     !4, !2
         24        ASSIGN                                                   !5, ~25
   26    25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $27     
         28        ASSIGN                                                   !6, $27
   27    29        ASSIGN                                                   !7, 0
         30      > JMP                                                      ->35
   28    31    >   INIT_STATIC_METHOD_CALL                                  'Foo', 'asdf'
         32        DO_FCALL                                      0  $30     
         33        ASSIGN                                                   !1, $30
   27    34        PRE_INC                                                  !7
         35    >   IS_SMALLER                                               !7, !0
         36      > JMPNZ                                                    ~33, ->31
   30    37    >   INIT_FCALL                                               'microtime'
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $34     
         40        ASSIGN                                                   !8, $34
   31    41        SUB                                              ~36     !8, !6
         42        ASSIGN                                                   !9, ~36
   33    43        DIV                                              ~38     !9, !5
         44        MUL                                              ~39     ~38, 100
         45        ASSIGN                                                   !10, ~39
   34    46        IS_SMALLER                                               !9, !5
         47      > JMPZ                                                     ~41, ->53
   35    48    >   INIT_FCALL                                               'printf'
         49        SEND_VAL                                                 'static+method+is+%25.2f%25%25+faster'
         50        SEND_VAR                                                 !10
         51        DO_ICALL                                                 
   34    52      > JMP                                                      ->57
   37    53    >   INIT_FCALL                                               'printf'
         54        SEND_VAL                                                 'function+call+is+%25.2f%25%25+faster'
         55        SEND_VAR                                                 !10
         56        DO_ICALL                                                 
   38    57    > > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A7Blr
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E > > RETURN                                                   1234
    4     1*     > RETURN                                                   null

End of function foo

Class Foo:
Function asdf:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A7Blr
function name:  asdf
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   1234
    9     1*     > RETURN                                                   null

End of function asdf

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.13 ms | 1009 KiB | 17 Q