3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo { private $bar; public function __construct(Bar $bar) { $this->bar = $bar; } } $bar = new Bar; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $reflect = new ReflectionClass('foo'); $constructor = $reflect->getConstructor(); } $t2 = microtime(true); echo 'getcons ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $constructor = method_exists('Foo', '__construct') ? new ReflectionMethod('Foo', '__construct') : null; } $t2 = microtime(true); echo 'rm: ' . ($t2-$t1) . '<br />';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 33
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 44
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 33
Branch analysis from position: 49
Branch analysis from position: 33
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 33
Branch analysis from position: 49
Branch analysis from position: 33
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 9
Branch analysis from position: 19
Branch analysis from position: 9
filename:       /in/5ETqZ
function name:  (null)
number of ops:  58
compiled vars:  !0 = $bar, !1 = $t1, !2 = $i, !3 = $reflect, !4 = $constructor, !5 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $6      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   19     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
   21     7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->17
   22     9    >   NEW                                              $12     'ReflectionClass'
         10        SEND_VAL_EX                                              'foo'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $12
   23    13        INIT_METHOD_CALL                                         !3, 'getConstructor'
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !4, $15
   21    16        PRE_INC                                                  !2
         17    >   IS_SMALLER                                               !2, 10000
         18      > JMPNZ                                                    ~18, ->9
   25    19    >   INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $19     
         22        ASSIGN                                                   !5, $19
   27    23        SUB                                              ~21     !5, !1
         24        CONCAT                                           ~22     'getcons+', ~21
         25        CONCAT                                           ~23     ~22, '%3Cbr+%2F%3E'
         26        ECHO                                                     ~23
   30    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $24     
         30        ASSIGN                                                   !1, $24
   32    31        ASSIGN                                                   !2, 0
         32      > JMP                                                      ->47
   33    33    >   INIT_FCALL                                               'method_exists'
         34        SEND_VAL                                                 'Foo'
         35        SEND_VAL                                                 '__construct'
         36        DO_ICALL                                         $27     
         37      > JMPZ                                                     $27, ->44
         38    >   NEW                                              $28     'ReflectionMethod'
         39        SEND_VAL_EX                                              'Foo'
         40        SEND_VAL_EX                                              '__construct'
         41        DO_FCALL                                      0          
         42        QM_ASSIGN                                        ~30     $28
         43      > JMP                                                      ->45
         44    >   QM_ASSIGN                                        ~30     null
         45    >   ASSIGN                                                   !4, ~30
   32    46        PRE_INC                                                  !2
         47    >   IS_SMALLER                                               !2, 10000
         48      > JMPNZ                                                    ~33, ->33
   35    49    >   INIT_FCALL                                               'microtime'
         50        SEND_VAL                                                 <true>
         51        DO_ICALL                                         $34     
         52        ASSIGN                                                   !5, $34
   37    53        SUB                                              ~36     !5, !1
         54        CONCAT                                           ~37     'rm%3A+', ~36
         55        CONCAT                                           ~38     ~37, '%3Cbr+%2F%3E'
         56        ECHO                                                     ~38
         57      > RETURN                                                   1

Class Bar: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5ETqZ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.56 ms | 1400 KiB | 17 Q