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 "dynamic: ", 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_array: ", 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 "function: ", microtime(true) - $startTime, PHP_EOL; // anonymous function $startTime = microtime(true); for ($i = 0; $i < 100000;) { $i = $function($i); } echo "anonymous function: ", microtime(true) - $startTime, PHP_EOL;
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 = 17
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 36
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 59
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
2 jumps found. (Code = 44) Position 1 = 84, Position 2 = 78
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 101
Branch analysis from position: 101
2 jumps found. (Code = 44) Position 1 = 103, Position 2 = 97
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
2 jumps found. (Code = 44) Position 1 = 122, Position 2 = 116
Branch analysis from position: 122
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 116
2 jumps found. (Code = 44) Position 1 = 122, Position 2 = 116
Branch analysis from position: 122
Branch analysis from position: 116
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 103, Position 2 = 97
Branch analysis from position: 103
Branch analysis from position: 97
Branch analysis from position: 78
2 jumps found. (Code = 44) Position 1 = 84, Position 2 = 78
Branch analysis from position: 84
Branch analysis from position: 78
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 59
Branch analysis from position: 65
Branch analysis from position: 59
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 36
Branch analysis from position: 46
Branch analysis from position: 36
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 17
Branch analysis from position: 23
Branch analysis from position: 17
filename:       /in/Jo2kL
function name:  (null)
number of ops:  130
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%2FJo2kL%3A14%240'
          4        ASSIGN                                                   !1, ~7
   23     5        INIT_FCALL                                               'phpversion'
          6        DO_ICALL                                         $9      
          7        ECHO                                                     $9
          8        ECHO                                                     '+'
          9        ECHO                                                     'Linux'
         10        ECHO                                                     '%0A'
   26    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
   27    15        ASSIGN                                                   !3, 0
         16      > JMP                                                      ->21
   28    17    >   INIT_METHOD_CALL                                         !0, 'dynamicMethod'
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0  $13     
         20        ASSIGN                                                   !3, $13
   27    21    >   IS_SMALLER                                               !3, 100000
         22      > JMPNZ                                                    ~15, ->17
   30    23    >   ECHO                                                     'dynamic%3A+'
         24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $16     
         27        SUB                                              ~17     $16, !2
         28        ECHO                                                     ~17
         29        ECHO                                                     '%0A'
   33    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $18     
         33        ASSIGN                                                   !2, $18
   34    34        ASSIGN                                                   !3, 0
         35      > JMP                                                      ->44
   35    36    >   INIT_ARRAY                                       ~21     !0
         37        ADD_ARRAY_ELEMENT                                ~21     'dynamicMethod'
         38        INIT_USER_CALL                                0          'call_user_func_array', ~21
         39        INIT_ARRAY                                       ~22     !3
         40        SEND_ARRAY                                               ~22
         41        CHECK_UNDEF_ARGS                                         
         42        DO_FCALL                                      0  $23     
         43        ASSIGN                                                   !3, $23
   34    44    >   IS_SMALLER                                               !3, 100000
         45      > JMPNZ                                                    ~25, ->36
   37    46    >   ECHO                                                     'call_user_func_array%3A+'
         47        INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $26     
         50        SUB                                              ~27     $26, !2
         51        ECHO                                                     ~27
         52        ECHO                                                     '%0A'
   40    53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $28     
         56        ASSIGN                                                   !2, $28
   41    57        ASSIGN                                                   !3, 0
         58      > JMP                                                      ->63
   42    59    >   INIT_STATIC_METHOD_CALL                                  'Test', 'staticMethod'
         60        SEND_VAR                                                 !3
         61        DO_FCALL                                      0  $31     
         62        ASSIGN                                                   !3, $31
   41    63    >   IS_SMALLER                                               !3, 100000
         64      > JMPNZ                                                    ~33, ->59
   44    65    >   ECHO                                                     'static%3A+'
         66        INIT_FCALL                                               'microtime'
         67        SEND_VAL                                                 <true>
         68        DO_ICALL                                         $34     
         69        SUB                                              ~35     $34, !2
         70        ECHO                                                     ~35
         71        ECHO                                                     '%0A'
   47    72        INIT_FCALL                                               'microtime'
         73        SEND_VAL                                                 <true>
         74        DO_ICALL                                         $36     
         75        ASSIGN                                                   !2, $36
   48    76        ASSIGN                                                   !3, 0
         77      > JMP                                                      ->82
   49    78    >   INIT_DYNAMIC_CALL                                        !0
         79        SEND_VAR_EX                                              !3
         80        DO_FCALL                                      0  $39     
         81        ASSIGN                                                   !3, $39
   48    82    >   IS_SMALLER                                               !3, 100000
         83      > JMPNZ                                                    ~41, ->78
   51    84    >   ECHO                                                     'invoke%3A+'
         85        INIT_FCALL                                               'microtime'
         86        SEND_VAL                                                 <true>
         87        DO_ICALL                                         $42     
         88        SUB                                              ~43     $42, !2
         89        ECHO                                                     ~43
         90        ECHO                                                     '%0A'
   54    91        INIT_FCALL                                               'microtime'
         92        SEND_VAL                                                 <true>
         93        DO_ICALL                                         $44     
         94        ASSIGN                                                   !2, $44
   55    95        ASSIGN                                                   !3, 0
         96      > JMP                                                      ->101
   56    97    >   INIT_FCALL                                               'testfunction'
         98        SEND_VAR                                                 !3
         99        DO_FCALL                                      0  $47     
        100        ASSIGN                                                   !3, $47
   55   101    >   IS_SMALLER                                               !3, 100000
        102      > JMPNZ                                                    ~49, ->97
   58   103    >   ECHO                                                     'function%3A+'
        104        INIT_FCALL                                               'microtime'
        105        SEND_VAL                                                 <true>
        106        DO_ICALL                                         $50     
        107        SUB                                              ~51     $50, !2
        108        ECHO                                                     ~51
        109        ECHO                                                     '%0A'
   61   110        INIT_FCALL                                               'microtime'
        111        SEND_VAL                                                 <true>
        112        DO_ICALL                                         $52     
        113        ASSIGN                                                   !2, $52
   62   114        ASSIGN                                                   !3, 0
        115      > JMP                                                      ->120
   63   116    >   INIT_DYNAMIC_CALL                                        !1
        117        SEND_VAR_EX                                              !3
        118        DO_FCALL                                      0  $55     
        119        ASSIGN                                                   !3, $55
   62   120    >   IS_SMALLER                                               !3, 100000
        121      > JMPNZ                                                    ~57, ->116
   65   122    >   ECHO                                                     'anonymous+function%3A+'
        123        INIT_FCALL                                               'microtime'
        124        SEND_VAL                                                 <true>
        125        DO_ICALL                                         $58     
        126        SUB                                              ~59     $58, !2
        127        ECHO                                                     ~59
        128        ECHO                                                     '%0A'
        129      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FJo2kL%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Jo2kL
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%2FJo2kL%3A14%240

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