3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(PHP_VERSION_ID < 50400) { return; } class Foo { function recurseBenchCallerContex($iterations, $recursionLimit) { if($recursionLimit > 0) { return $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(); } var_dump('debug_backtrace full', microtime(true) - $start); } } $foo = new Foo; $foo->recurseBenchCallerContex(1000, 100);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 2
Branch analysis from position: 1
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pRPe8
function name:  (null)
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E > > JMPZ                                                     <false>, ->2
    5     1    > > RETURN                                                   null
   38     2    >   NEW                                              $1      'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   40     5        INIT_METHOD_CALL                                         !0, 'recurseBenchCallerContex'
          6        SEND_VAL_EX                                              1000
          7        SEND_VAL_EX                                              100
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

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

End of function recursebenchcallercontex

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.88 ms | 1400 KiB | 19 Q