3v4l.org

run code in 500+ PHP versions simultaneously
<?php class foo { public static function bar() { return __METHOD__; } } function directCall() { return foo::bar($_SERVER['REQUEST_TIME']); } function variableCall() { return call_user_func(array('foo', 'bar'), $_SERVER['REQUEST_TIME']); } function reflectedCall() { return (new ReflectionMethod('foo', 'bar'))->invoke(null, $_SERVER['REQUEST_TIME']); } function Benchmark($callbacks, $iterations = 100, $relative = false) { set_time_limit(0); if (count($callbacks = array_filter((array) $callbacks, 'is_callable')) > 0) { $result = array_fill_keys($callbacks, 0); $arguments = array_slice(func_get_args(), 3); for ($i = 0; $i < $iterations; ++$i) { foreach ($result as $key => $value) { $value = microtime(true); call_user_func_array($key, $arguments); $result[$key] += microtime(true) - $value; } } asort($result, SORT_NUMERIC); foreach (array_reverse($result) as $key => $value) { if ($relative === true) { $value /= reset($result); } $result[$key] = number_format($value, 8, '.', ''); } return $result; } return false; } print_r(Benchmark(array('directCall', 'variableCall', 'reflectedCall'), 1000000));

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24bLS
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   58     0  E >   INIT_FCALL                                                   'print_r'
          1        INIT_FCALL                                                   'benchmark'
          2        SEND_VAL                                                     <array>
          3        SEND_VAL                                                     1000000
          4        DO_FCALL                                          0  $0      
          5        SEND_VAR                                                     $0
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function directcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24bLS
function name:  directCall
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   INIT_STATIC_METHOD_CALL                                      'foo', 'bar'
          1        FETCH_R                          global              ~0      '_SERVER'
          2        FETCH_DIM_R                                          ~1      ~0, 'REQUEST_TIME'
          3        SEND_VAL                                                     ~1
          4        DO_FCALL                                          0  $2      
          5      > RETURN                                                       $2
   11     6*     > RETURN                                                       null

End of function directcall

Function variablecall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24bLS
function name:  variableCall
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   INIT_USER_CALL                                    1          'call_user_func', <array>
          1        FETCH_R                          global              ~0      '_SERVER'
          2        FETCH_DIM_R                                          ~1      ~0, 'REQUEST_TIME'
          3        SEND_USER                                                    ~1
          4        DO_FCALL                                          0  $2      
          5      > RETURN                                                       $2
   15     6*     > RETURN                                                       null

End of function variablecall

Function reflectedcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24bLS
function name:  reflectedCall
number of ops:  13
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   NEW                                                  $0      'ReflectionMethod'
          1        SEND_VAL_EX                                                  'foo'
          2        SEND_VAL_EX                                                  'bar'
          3        DO_FCALL                                          0          
          4        INIT_METHOD_CALL                                             $0, 'invoke'
          5        SEND_VAL_EX                                                  null
          6        CHECK_FUNC_ARG                                               
          7        FETCH_FUNC_ARG                   global              $2      '_SERVER'
          8        FETCH_DIM_FUNC_ARG                                   $3      $2, 'REQUEST_TIME'
          9        SEND_FUNC_ARG                                                $3
         10        DO_FCALL                                          0  $4      
         11      > RETURN                                                       $4
   19    12*     > RETURN                                                       null

End of function reflectedcall

Function benchmark:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 73
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 24
Branch analysis from position: 46
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 71
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 71
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 62
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 62
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 42
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 42
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 24
Branch analysis from position: 46
Branch analysis from position: 24
Branch analysis from position: 42
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24bLS
function name:  Benchmark
number of ops:  75
compiled vars:  !0 = $callbacks, !1 = $iterations, !2 = $relative, !3 = $result, !4 = $arguments, !5 = $i, !6 = $value, !7 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      100
          2        RECV_INIT                                            !2      <false>
   23     3        INIT_FCALL                                                   'set_time_limit'
          4        SEND_VAL                                                     0
          5        DO_ICALL                                                     
   25     6        INIT_FCALL                                                   'array_filter'
          7        CAST                                              7  ~9      !0
          8        SEND_VAL                                                     ~9
          9        SEND_VAL                                                     'is_callable'
         10        DO_ICALL                                             $10     
         11        ASSIGN                                               ~11     !0, $10
         12        COUNT                                                ~12     ~11
         13        IS_SMALLER                                                   0, ~12
         14      > JMPZ                                                         ~13, ->73
   27    15    >   INIT_FCALL                                                   'array_fill_keys'
         16        SEND_VAR                                                     !0
         17        SEND_VAL                                                     0
         18        DO_ICALL                                             $14     
         19        ASSIGN                                                       !3, $14
   28    20        FUNC_GET_ARGS                                        ~16     3
         21        ASSIGN                                                       !4, ~16
   30    22        ASSIGN                                                       !5, 0
         23      > JMP                                                          ->44
   32    24    > > FE_RESET_R                                           $19     !3, ->42
         25    > > FE_FETCH_R                                           ~20     $19, !6, ->42
         26    >   ASSIGN                                                       !7, ~20
   34    27        INIT_FCALL                                                   'microtime'
         28        SEND_VAL                                                     <true>
         29        DO_ICALL                                             $22     
         30        ASSIGN                                                       !6, $22
   35    31        INIT_USER_CALL                                    0          'call_user_func_array', !7
         32        SEND_ARRAY                                                   !4
         33        CHECK_UNDEF_ARGS                                             
         34        DO_FCALL                                          1          
   36    35        INIT_FCALL                                                   'microtime'
         36        SEND_VAL                                                     <true>
         37        DO_ICALL                                             $26     
         38        SUB                                                  ~27     $26, !6
         39        ASSIGN_DIM_OP                    +=               1          !3, !7
         40        OP_DATA                                                      ~27
   32    41      > JMP                                                          ->25
         42    >   FE_FREE                                                      $19
   30    43        PRE_INC                                                      !5
         44    >   IS_SMALLER                                                   !5, !1
         45      > JMPNZ                                                        ~29, ->24
   40    46    >   INIT_FCALL                                                   'asort'
         47        SEND_REF                                                     !3
         48        SEND_VAL                                                     1
         49        DO_ICALL                                                     
   42    50        INIT_FCALL                                                   'array_reverse'
         51        SEND_VAR                                                     !3
         52        DO_ICALL                                             $31     
         53      > FE_RESET_R                                           $32     $31, ->71
         54    > > FE_FETCH_R                                           ~33     $32, !6, ->71
         55    >   ASSIGN                                                       !7, ~33
   44    56        TYPE_CHECK                                        8          !2
         57      > JMPZ                                                         ~35, ->62
   46    58    >   INIT_FCALL                                                   'reset'
         59        SEND_REF                                                     !3
         60        DO_ICALL                                             $36     
         61        ASSIGN_OP                                         4          !6, $36
   49    62    >   INIT_FCALL                                                   'number_format'
         63        SEND_VAR                                                     !6
         64        SEND_VAL                                                     8
         65        SEND_VAL                                                     '.'
         66        SEND_VAL                                                     ''
         67        DO_ICALL                                             $39     
         68        ASSIGN_DIM                                                   !3, !7
         69        OP_DATA                                                      $39
   42    70      > JMP                                                          ->54
         71    >   FE_FREE                                                      $32
   52    72      > RETURN                                                       !3
   55    73    > > RETURN                                                       <false>
   56    74*     > RETURN                                                       null

End of function benchmark

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

End of function bar

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.91 ms | 2747 KiB | 23 Q