3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function isOk() { return $this->log(true, __FUNCTION__); } public function isFalse() { return $this->log(false); } private function log(mixed $result, string $methodName = null) { if (!isset($methodName)) { $methodName = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]["function"]; } //echo $methodName, "\n"; } } $c = new Test; for($t=hrtime(true),$i=0;$i<1e6;++$i) $c->isOk(); printf("magic const: %.3fms\n", (hrtime(true)-$t)/1000_000); for($t=hrtime(true),$i=0;$i<1e6;++$i) $c->isFalse(); printf("debug trace: %.3fms\n", (hrtime(true)-$t)/1000_000);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 29
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 29
Branch analysis from position: 34
Branch analysis from position: 29
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 9
Branch analysis from position: 14
Branch analysis from position: 9
filename:       /in/Od7cd
function name:  (null)
number of ops:  44
compiled vars:  !0 = $c, !1 = $t, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $3      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   25     3        INIT_FCALL                                               'hrtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !1, $6
          7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->12
   26     9    >   INIT_METHOD_CALL                                         !0, 'isOk'
         10        DO_FCALL                                      0          
   25    11        PRE_INC                                                  !2
         12    >   IS_SMALLER                                               !2, 1.0e+6
         13      > JMPNZ                                                    ~11, ->9
   27    14    >   INIT_FCALL                                               'printf'
         15        SEND_VAL                                                 'magic+const%3A+%25.3fms%0A'
         16        INIT_FCALL                                               'hrtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        SUB                                              ~13     $12, !1
         20        DIV                                              ~14     ~13, 1000000
         21        SEND_VAL                                                 ~14
         22        DO_ICALL                                                 
   28    23        INIT_FCALL                                               'hrtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $16     
         26        ASSIGN                                                   !1, $16
         27        ASSIGN                                                   !2, 0
         28      > JMP                                                      ->32
   29    29    >   INIT_METHOD_CALL                                         !0, 'isFalse'
         30        DO_FCALL                                      0          
   28    31        PRE_INC                                                  !2
         32    >   IS_SMALLER                                               !2, 1.0e+6
         33      > JMPNZ                                                    ~21, ->29
   30    34    >   INIT_FCALL                                               'printf'
         35        SEND_VAL                                                 'debug+trace%3A+%25.3fms%0A'
         36        INIT_FCALL                                               'hrtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $22     
         39        SUB                                              ~23     $22, !1
         40        DIV                                              ~24     ~23, 1000000
         41        SEND_VAL                                                 ~24
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Class Test:
Function isok:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Od7cd
function name:  isOk
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'log'
          1        SEND_VAL_EX                                              <true>
          2        SEND_VAL_EX                                              'isOk'
          3        DO_FCALL                                      0  $0      
          4      > RETURN                                                   $0
    8     5*     > RETURN                                                   null

End of function isok

Function isfalse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Od7cd
function name:  isFalse
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_METHOD_CALL                                         'log'
          1        SEND_VAL_EX                                              <false>
          2        DO_FCALL                                      0  $0      
          3      > RETURN                                                   $0
   13     4*     > RETURN                                                   null

End of function isfalse

Function log:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/Od7cd
function name:  log
number of ops:  13
compiled vars:  !0 = $result, !1 = $methodName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   17     2        ISSET_ISEMPTY_CV                                 ~2      !1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
   18     5    >   INIT_FCALL                                               'debug_backtrace'
          6        SEND_VAL                                                 2
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $4      
          9        FETCH_DIM_R                                      ~5      $4, 1
         10        FETCH_DIM_R                                      ~6      ~5, 'function'
         11        ASSIGN                                                   !1, ~6
   21    12    > > RETURN                                                   null

End of function log

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.32 ms | 1405 KiB | 19 Q