3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { public static function foo() { return static::class; } public static function bar() { return get_called_class(); } } class Child extends Base {} profile("Parent, static::class", function () { Base::foo();}); profile("Parent, get_called_class", function () { Base::bar();}); profile("Child, static::class", function () { Child::foo();}); profile("Child, get_called_class", function () { Child::bar();}); function profile($what, callable $func) { static $previous; if (!$previous) $previous = microtime(true); for ($a = 0; $a<=1000000; $a++) { $func(); }; $now = microtime(true); echo sprintf("%s took %.4f seconds", $what, $now - $previous), PHP_EOL; $previous = $now; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qaXln
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL_BY_NAME                                       'profile'
          1        SEND_VAL_EX                                              'Parent%2C+static%3A%3Aclass'
          2        DECLARE_LAMBDA_FUNCTION                          ~0      [0]
          3        SEND_VAL_EX                                              ~0
          4        DO_FCALL                                      0          
   18     5        INIT_FCALL_BY_NAME                                       'profile'
          6        SEND_VAL_EX                                              'Parent%2C+get_called_class'
          7        DECLARE_LAMBDA_FUNCTION                          ~2      [1]
          8        SEND_VAL_EX                                              ~2
          9        DO_FCALL                                      0          
   19    10        INIT_FCALL_BY_NAME                                       'profile'
         11        SEND_VAL_EX                                              'Child%2C+static%3A%3Aclass'
         12        DECLARE_LAMBDA_FUNCTION                          ~4      [2]
         13        SEND_VAL_EX                                              ~4
         14        DO_FCALL                                      0          
   20    15        INIT_FCALL_BY_NAME                                       'profile'
         16        SEND_VAL_EX                                              'Child%2C+get_called_class'
         17        DECLARE_LAMBDA_FUNCTION                          ~6      [3]
         18        SEND_VAL_EX                                              ~6
         19        DO_FCALL                                      0          
   33    20      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qaXln
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_STATIC_METHOD_CALL                                  'Base', 'foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qaXln
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_STATIC_METHOD_CALL                                  'Base', 'bar'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qaXln
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                  'Child', 'foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qaXln
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'Child', 'bar'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   null

End of Dynamic Function 3

Function profile:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 11
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 11
Branch analysis from position: 16
Branch analysis from position: 11
Branch analysis from position: 9
filename:       /in/qaXln
function name:  profile
number of ops:  30
compiled vars:  !0 = $what, !1 = $func, !2 = $previous, !3 = $a, !4 = $now
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        BIND_STATIC                                              !2
   25     3        BOOL_NOT                                         ~5      !2
          4      > JMPZ                                                     ~5, ->9
          5    >   INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   27     9    >   ASSIGN                                                   !3, 0
         10      > JMP                                                      ->14
         11    >   INIT_DYNAMIC_CALL                                        !1
         12        DO_FCALL                                      0          
         13        PRE_INC                                                  !3
         14    >   IS_SMALLER_OR_EQUAL                                      !3, 1000000
         15      > JMPNZ                                                    ~11, ->11
   29    16    >   INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !4, $12
   30    20        INIT_FCALL                                               'sprintf'
         21        SEND_VAL                                                 '%25s+took+%25.4f+seconds'
         22        SEND_VAR                                                 !0
         23        SUB                                              ~14     !4, !2
         24        SEND_VAL                                                 ~14
         25        DO_ICALL                                         $15     
         26        ECHO                                                     $15
         27        ECHO                                                     '%0A'
   32    28        ASSIGN                                                   !2, !4
   33    29      > RETURN                                                   null

End of function profile

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

End of function foo

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

End of function bar

End of class Base.

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

End of function foo

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

End of function bar

End of class Child.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.89 ms | 1436 KiB | 15 Q