3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function dynamicMethod($a) { return $a + 1; } public static function staticMethod($a) { return $a + 1; } public function __invoke($a) { return $a + 1; } } $object = new Test(); ///////////////////////// $function = function ($a) { return $a + 1; }; function testFunction($a) { return $a + 1; } // env //echo phpversion(), " ", PHP_OS, PHP_EOL; // dynamic $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object->dynamicMethod($i); } echo "dyn: ", microtime(true) - $startTime, PHP_EOL; // dynamic call_user_func $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = call_user_func_array(array($object, 'dynamicMethod'), array($i)); } echo "call_user_func: ", microtime(true) - $startTime, PHP_EOL; // static $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = Test::staticMethod($i); } echo "static: ", microtime(true) - $startTime, PHP_EOL; // invoke $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $object($i); } echo "invoke: ", microtime(true) - $startTime, PHP_EOL; // function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = testFunction($i); } echo "func: ", microtime(true) - $startTime, PHP_EOL; // anonymous function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $function($i); } echo "anon: ", microtime(true) - $startTime, PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 11
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 30
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 53
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 72
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 95
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 91
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
2 jumps found. (Code = 44) Position 1 = 116, Position 2 = 110
Branch analysis from position: 116
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 110
2 jumps found. (Code = 44) Position 1 = 116, Position 2 = 110
Branch analysis from position: 116
Branch analysis from position: 110
Branch analysis from position: 91
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 91
Branch analysis from position: 97
Branch analysis from position: 91
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 72
Branch analysis from position: 78
Branch analysis from position: 72
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 53
Branch analysis from position: 59
Branch analysis from position: 53
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 30
Branch analysis from position: 40
Branch analysis from position: 30
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 11
Branch analysis from position: 17
Branch analysis from position: 11
filename:       /in/MH1qN
function name:  (null)
number of ops:  124
compiled vars:  !0 = $object, !1 = $function, !2 = $startTime, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $4      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   14     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMH1qN%3A14%240'
          4        ASSIGN                                                   !1, ~7
   26     5        INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !2, $9
   27     9        ASSIGN                                                   !3, 0
         10      > JMP                                                      ->15
   28    11    >   INIT_METHOD_CALL                                         !0, 'dynamicMethod'
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !3, $12
   27    15    >   IS_SMALLER                                               !3, 100000
         16      > JMPNZ                                                    ~14, ->11
   30    17    >   ECHO                                                     'dyn%3A+'
         18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $15     
         21        SUB                                              ~16     $15, !2
         22        ECHO                                                     ~16
         23        ECHO                                                     '%0A'
   33    24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $17     
         27        ASSIGN                                                   !2, $17
   34    28        ASSIGN                                                   !3, 0
         29      > JMP                                                      ->38
   35    30    >   INIT_ARRAY                                       ~20     !0
         31        ADD_ARRAY_ELEMENT                                ~20     'dynamicMethod'
         32        INIT_USER_CALL                                0          'call_user_func_array', ~20
         33        INIT_ARRAY                                       ~21     !3
         34        SEND_ARRAY                                               ~21
         35        CHECK_UNDEF_ARGS                                         
         36        DO_FCALL                                      0  $22     
         37        ASSIGN                                                   !3, $22
   34    38    >   IS_SMALLER                                               !3, 100000
         39      > JMPNZ                                                    ~24, ->30
   37    40    >   ECHO                                                     'call_user_func%3A+'
         41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $25     
         44        SUB                                              ~26     $25, !2
         45        ECHO                                                     ~26
         46        ECHO                                                     '%0A'
   40    47        INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $27     
         50        ASSIGN                                                   !2, $27
   41    51        ASSIGN                                                   !3, 0
         52      > JMP                                                      ->57
   42    53    >   INIT_STATIC_METHOD_CALL                                  'Test', 'staticMethod'
         54        SEND_VAR                                                 !3
         55        DO_FCALL                                      0  $30     
         56        ASSIGN                                                   !3, $30
   41    57    >   IS_SMALLER                                               !3, 100000
         58      > JMPNZ                                                    ~32, ->53
   44    59    >   ECHO                                                     'static%3A+'
         60        INIT_FCALL                                               'microtime'
         61        SEND_VAL                                                 <true>
         62        DO_ICALL                                         $33     
         63        SUB                                              ~34     $33, !2
         64        ECHO                                                     ~34
         65        ECHO                                                     '%0A'
   47    66        INIT_FCALL                                               'microtime'
         67        SEND_VAL                                                 <true>
         68        DO_ICALL                                         $35     
         69        ASSIGN                                                   !2, $35
   48    70        ASSIGN                                                   !3, 0
         71      > JMP                                                      ->76
   49    72    >   INIT_DYNAMIC_CALL                                        !0
         73        SEND_VAR_EX                                              !3
         74        DO_FCALL                                      0  $38     
         75        ASSIGN                                                   !3, $38
   48    76    >   IS_SMALLER                                               !3, 100000
         77      > JMPNZ                                                    ~40, ->72
   51    78    >   ECHO                                                     'invoke%3A+'
         79        INIT_FCALL                                               'microtime'
         80        SEND_VAL                                                 <true>
         81        DO_ICALL                                         $41     
         82        SUB                                              ~42     $41, !2
         83        ECHO                                                     ~42
         84        ECHO                                                     '%0A'
   54    85        INIT_FCALL                                               'microtime'
         86        SEND_VAL                                                 <true>
         87        DO_ICALL                                         $43     
         88        ASSIGN                                                   !2, $43
   55    89        ASSIGN                                                   !3, 0
         90      > JMP                                                      ->95
   56    91    >   INIT_FCALL                                               'testfunction'
         92        SEND_VAR                                                 !3
         93        DO_FCALL                                      0  $46     
         94        ASSIGN                                                   !3, $46
   55    95    >   IS_SMALLER                                               !3, 100000
         96      > JMPNZ                                                    ~48, ->91
   58    97    >   ECHO                                                     'func%3A+'
         98        INIT_FCALL                                               'microtime'
         99        SEND_VAL                                                 <true>
        100        DO_ICALL                                         $49     
        101        SUB                                              ~50     $49, !2
        102        ECHO                                                     ~50
        103        ECHO                                                     '%0A'
   61   104        INIT_FCALL                                               'microtime'
        105        SEND_VAL                                                 <true>
        106        DO_ICALL                                         $51     
        107        ASSIGN                                                   !2, $51
   62   108        ASSIGN                                                   !3, 0
        109      > JMP                                                      ->114
   63   110    >   INIT_DYNAMIC_CALL                                        !1
        111        SEND_VAR_EX                                              !3
        112        DO_FCALL                                      0  $54     
        113        ASSIGN                                                   !3, $54
   62   114    >   IS_SMALLER                                               !3, 100000
        115      > JMPNZ                                                    ~56, ->110
   65   116    >   ECHO                                                     'anon%3A+'
        117        INIT_FCALL                                               'microtime'
        118        SEND_VAL                                                 <true>
        119        DO_ICALL                                         $57     
        120        SUB                                              ~58     $57, !2
        121        ECHO                                                     ~58
        122        ECHO                                                     '%0A'
        123      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMH1qN%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MH1qN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
   16     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMH1qN%3A14%240

Function testfunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MH1qN
function name:  testFunction
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
   20     3*     > RETURN                                                   null

End of function testfunction

Class Test:
Function dynamicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MH1qN
function name:  dynamicMethod
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function dynamicmethod

Function staticmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MH1qN
function name:  staticMethod
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function staticmethod

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MH1qN
function name:  __invoke
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function __invoke

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.03 ms | 1415 KiB | 16 Q