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 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 51
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 76, Position 2 = 70
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
2 jumps found. (Code = 44) Position 1 = 95, Position 2 = 89
Branch analysis from position: 95
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 95, Position 2 = 89
Branch analysis from position: 95
Branch analysis from position: 89
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 76, Position 2 = 70
Branch analysis from position: 76
Branch analysis from position: 70
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 51
Branch analysis from position: 57
Branch analysis from position: 51
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
Branch analysis from position: 28
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/VNPZ8
function name:  (null)
number of ops:  103
compiled vars:  !0 = $object, !1 = $startTime, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $3      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   26     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !1, $6
   27     7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->13
   28     9    >   INIT_METHOD_CALL                                         !0, 'dynamicMethod'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0  $9      
         12        ASSIGN                                                   !2, $9
   27    13    >   IS_SMALLER                                               !2, 100000
         14      > JMPNZ                                                    ~11, ->9
   30    15    >   ECHO                                                     'dyn%3A+'
         16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        SUB                                              ~13     $12, !1
         20        ECHO                                                     ~13
         21        ECHO                                                     '%0A'
   33    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $14     
         25        ASSIGN                                                   !1, $14
   34    26        ASSIGN                                                   !2, 0
         27      > JMP                                                      ->36
   35    28    >   INIT_ARRAY                                       ~17     !0
         29        ADD_ARRAY_ELEMENT                                ~17     'dynamicMethod'
         30        INIT_USER_CALL                                0          'call_user_func_array', ~17
         31        INIT_ARRAY                                       ~18     !2
         32        SEND_ARRAY                                               ~18
         33        CHECK_UNDEF_ARGS                                         
         34        DO_FCALL                                      0  $19     
         35        ASSIGN                                                   !2, $19
   34    36    >   IS_SMALLER                                               !2, 100000
         37      > JMPNZ                                                    ~21, ->28
   37    38    >   ECHO                                                     'call_user_func%3A+'
         39        INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $22     
         42        SUB                                              ~23     $22, !1
         43        ECHO                                                     ~23
         44        ECHO                                                     '%0A'
   40    45        INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $24     
         48        ASSIGN                                                   !1, $24
   41    49        ASSIGN                                                   !2, 0
         50      > JMP                                                      ->55
   42    51    >   INIT_STATIC_METHOD_CALL                                  'Test', 'staticMethod'
         52        SEND_VAR                                                 !2
         53        DO_FCALL                                      0  $27     
         54        ASSIGN                                                   !2, $27
   41    55    >   IS_SMALLER                                               !2, 100000
         56      > JMPNZ                                                    ~29, ->51
   44    57    >   ECHO                                                     'static%3A+'
         58        INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $30     
         61        SUB                                              ~31     $30, !1
         62        ECHO                                                     ~31
         63        ECHO                                                     '%0A'
   47    64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $32     
         67        ASSIGN                                                   !1, $32
   48    68        ASSIGN                                                   !2, 0
         69      > JMP                                                      ->74
   49    70    >   INIT_DYNAMIC_CALL                                        !0
         71        SEND_VAR_EX                                              !2
         72        DO_FCALL                                      0  $35     
         73        ASSIGN                                                   !2, $35
   48    74    >   IS_SMALLER                                               !2, 100000
         75      > JMPNZ                                                    ~37, ->70
   51    76    >   ECHO                                                     'invoke%3A+'
         77        INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $38     
         80        SUB                                              ~39     $38, !1
         81        ECHO                                                     ~39
         82        ECHO                                                     '%0A'
   54    83        INIT_FCALL                                               'microtime'
         84        SEND_VAL                                                 <true>
         85        DO_ICALL                                         $40     
         86        ASSIGN                                                   !1, $40
   55    87        ASSIGN                                                   !2, 0
         88      > JMP                                                      ->93
   56    89    >   INIT_FCALL                                               'testfunction'
         90        SEND_VAR                                                 !2
         91        DO_FCALL                                      0  $43     
         92        ASSIGN                                                   !2, $43
   55    93    >   IS_SMALLER                                               !2, 100000
         94      > JMPNZ                                                    ~45, ->89
   58    95    >   ECHO                                                     'func%3A+'
         96        INIT_FCALL                                               'microtime'
         97        SEND_VAL                                                 <true>
         98        DO_ICALL                                         $46     
         99        SUB                                              ~47     $46, !1
        100        ECHO                                                     ~47
        101        ECHO                                                     '%0A'
   65   102      > RETURN                                                   1

Function testfunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VNPZ8
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/VNPZ8
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/VNPZ8
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/VNPZ8
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:
147.15 ms | 1411 KiB | 16 Q