3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function recurseBenchCallerContex($iterations, $recursionLimit) { if($recursionLimit > 0) { $this->recurseBenchCallerContex($iterations, $recursionLimit - 1); } $start = microtime(true); for($c = 0; $c < $iterations; $c++) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $class = isset($trace[1]['class']) ? $trace[1]['class'] : null; } var_dump('debug_backtrace', microtime(true) - $start); $start = microtime(true); for($c = 0; $c < $iterations; $c++) { $class = get_called_class(); } $start = microtime(true); var_dump('get_called_class', microtime(true) - $start); } } $foo = new Foo; $foo->recurseBenchCallerContex(10000, 0);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SI1NG
function name:  (null)
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   34     3        INIT_METHOD_CALL                                         !0, 'recurseBenchCallerContex'
          4        SEND_VAL_EX                                              10000
          5        SEND_VAL_EX                                              0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class Foo:
Function recursebenchcallercontex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 46
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 46
Branch analysis from position: 51
Branch analysis from position: 46
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
Branch analysis from position: 15
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/SI1NG
function name:  recurseBenchCallerContex
number of ops:  64
compiled vars:  !0 = $iterations, !1 = $recursionLimit, !2 = $start, !3 = $c, !4 = $trace, !5 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        IS_SMALLER                                               0, !1
          3      > JMPZ                                                     ~6, ->9
    8     4    >   INIT_METHOD_CALL                                         'recurseBenchCallerContex'
          5        SEND_VAR_EX                                              !0
          6        SUB                                              ~7      !1, 1
          7        SEND_VAL_EX                                              ~7
          8        DO_FCALL                                      0          
   11     9    >   INIT_FCALL                                               'microtime'
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !2, $9
   13    13        ASSIGN                                                   !3, 0
         14      > JMP                                                      ->30
   14    15    >   INIT_FCALL                                               'debug_backtrace'
         16        SEND_VAL                                                 2
         17        SEND_VAL                                                 2
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !4, $12
   15    20        FETCH_DIM_IS                                     ~14     !4, 1
         21        ISSET_ISEMPTY_DIM_OBJ                         0          ~14, 'class'
         22      > JMPZ                                                     ~15, ->27
         23    >   FETCH_DIM_R                                      ~16     !4, 1
         24        FETCH_DIM_R                                      ~17     ~16, 'class'
         25        QM_ASSIGN                                        ~18     ~17
         26      > JMP                                                      ->28
         27    >   QM_ASSIGN                                        ~18     null
         28    >   ASSIGN                                                   !5, ~18
   13    29        PRE_INC                                                  !3
         30    >   IS_SMALLER                                               !3, !0
         31      > JMPNZ                                                    ~21, ->15
   18    32    >   INIT_FCALL                                               'var_dump'
         33        SEND_VAL                                                 'debug_backtrace'
         34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $22     
         37        SUB                                              ~23     $22, !2
         38        SEND_VAL                                                 ~23
         39        DO_ICALL                                                 
   20    40        INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $25     
         43        ASSIGN                                                   !2, $25
   22    44        ASSIGN                                                   !3, 0
         45      > JMP                                                      ->49
   23    46    >   GET_CALLED_CLASS                                 ~28     
         47        ASSIGN                                                   !5, ~28
   22    48        PRE_INC                                                  !3
         49    >   IS_SMALLER                                               !3, !0
         50      > JMPNZ                                                    ~31, ->46
   25    51    >   INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $32     
         54        ASSIGN                                                   !2, $32
   26    55        INIT_FCALL                                               'var_dump'
         56        SEND_VAL                                                 'get_called_class'
         57        INIT_FCALL                                               'microtime'
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $34     
         60        SUB                                              ~35     $34, !2
         61        SEND_VAL                                                 ~35
         62        DO_ICALL                                                 
   28    63      > RETURN                                                   null

End of function recursebenchcallercontex

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.47 ms | 1400 KiB | 19 Q