3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar() {} } $foo = new Foo(); $method = 'bar'; $args = array(); $iterations = 100000; $start = microtime(true); for($i = 0; $i < $iterations; $i++) { $foo->{$method}($args); } echo 'Calling directly on object: ' . (microtime(true) - $start) . PHP_EOL; $start = microtime(true); for($i = 0; $i < $iterations; $i++) { call_user_func(array($foo, $method), $args); } echo 'Calling call_user_func: ' . (microtime(true) - $start) . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 31
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 31
Branch analysis from position: 39
Branch analysis from position: 31
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 12
Branch analysis from position: 18
Branch analysis from position: 12
filename:       /in/UubGr
function name:  (null)
number of ops:  47
compiled vars:  !0 = $foo, !1 = $method, !2 = $args, !3 = $iterations, !4 = $start, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $6      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   10     3        ASSIGN                                                   !1, 'bar'
   11     4        ASSIGN                                                   !2, <array>
   13     5        ASSIGN                                                   !3, 100000
   15     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $12     
          9        ASSIGN                                                   !4, $12
   16    10        ASSIGN                                                   !5, 0
         11      > JMP                                                      ->16
   17    12    >   INIT_METHOD_CALL                                         !0, !1
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
   16    15        PRE_INC                                                  !5
         16    >   IS_SMALLER                                               !5, !3
         17      > JMPNZ                                                    ~17, ->12
   20    18    >   INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $18     
         21        SUB                                              ~19     $18, !4
         22        CONCAT                                           ~20     'Calling+directly+on+object%3A+', ~19
         23        CONCAT                                           ~21     ~20, '%0A'
         24        ECHO                                                     ~21
   22    25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $22     
         28        ASSIGN                                                   !4, $22
   23    29        ASSIGN                                                   !5, 0
         30      > JMP                                                      ->37
   24    31    >   INIT_ARRAY                                       ~25     !0
         32        ADD_ARRAY_ELEMENT                                ~25     !1
         33        INIT_USER_CALL                                1          'call_user_func', ~25
         34        SEND_USER                                                !2
         35        DO_FCALL                                      0          
   23    36        PRE_INC                                                  !5
         37    >   IS_SMALLER                                               !5, !3
         38      > JMPNZ                                                    ~28, ->31
   27    39    >   INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $29     
         42        SUB                                              ~30     $29, !4
         43        CONCAT                                           ~31     'Calling+call_user_func%3A+', ~30
         44        CONCAT                                           ~32     ~31, '%0A'
         45        ECHO                                                     ~32
         46      > RETURN                                                   1

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.29 ms | 1392 KiB | 15 Q