3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo { private $bar; public function __construct(Bar $bar) { $this->bar = $bar; } } $reflect = new ReflectionClass('foo'); $constructor = $reflect->getConstructor(); $bar = new Bar; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo($bar); } $t2 = microtime(true); echo 'new keyword: ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceArgs([$bar]); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, [$bar]); } $t2 = microtime(true); echo 'newinstancewithoutconstructor: ' . ($t2-$t1) . '<br />';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 37
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 59
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 59
Branch analysis from position: 70
Branch analysis from position: 59
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 37
Branch analysis from position: 45
Branch analysis from position: 37
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 16
Branch analysis from position: 23
Branch analysis from position: 16
filename:       /in/oXneA
function name:  (null)
number of ops:  79
compiled vars:  !0 = $reflect, !1 = $constructor, !2 = $bar, !3 = $t1, !4 = $i, !5 = $foo, !6 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $7      'ReflectionClass'
          1        SEND_VAL_EX                                              'foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $7
   16     4        INIT_METHOD_CALL                                         !0, 'getConstructor'
          5        DO_FCALL                                      0  $10     
          6        ASSIGN                                                   !1, $10
   18     7        NEW                                              $12     'Bar'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $12
   20    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $15     
         13        ASSIGN                                                   !3, $15
   22    14        ASSIGN                                                   !4, 0
         15      > JMP                                                      ->21
   23    16    >   NEW                                              $18     'Foo'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !5, $18
   22    20        PRE_INC                                                  !4
         21    >   IS_SMALLER                                               !4, 10000
         22      > JMPNZ                                                    ~22, ->16
   25    23    >   INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $23     
         26        ASSIGN                                                   !6, $23
   27    27        SUB                                              ~25     !6, !3
         28        CONCAT                                           ~26     'new+keyword%3A+', ~25
         29        CONCAT                                           ~27     ~26, '%3Cbr+%2F%3E'
         30        ECHO                                                     ~27
   30    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $28     
         34        ASSIGN                                                   !3, $28
   32    35        ASSIGN                                                   !4, 0
         36      > JMP                                                      ->43
   33    37    >   INIT_METHOD_CALL                                         !0, 'newInstanceArgs'
         38        INIT_ARRAY                                       ~31     !2
         39        SEND_VAL_EX                                              ~31
         40        DO_FCALL                                      0  $32     
         41        ASSIGN                                                   !5, $32
   32    42        PRE_INC                                                  !4
         43    >   IS_SMALLER                                               !4, 10000
         44      > JMPNZ                                                    ~35, ->37
   35    45    >   INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $36     
         48        ASSIGN                                                   !6, $36
   37    49        SUB                                              ~38     !6, !3
         50        CONCAT                                           ~39     'newinstanceargs%3A+', ~38
         51        CONCAT                                           ~40     ~39, '%3Cbr+%2F%3E'
         52        ECHO                                                     ~40
   40    53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $41     
         56        ASSIGN                                                   !3, $41
   42    57        ASSIGN                                                   !4, 0
         58      > JMP                                                      ->68
   43    59    >   INIT_METHOD_CALL                                         !0, 'newInstanceWithoutConstructor'
         60        DO_FCALL                                      0  $44     
         61        ASSIGN                                                   !5, $44
   44    62        INIT_METHOD_CALL                                         !1, 'invokeArgs'
         63        SEND_VAR_EX                                              !5
         64        INIT_ARRAY                                       ~46     !2
         65        SEND_VAL_EX                                              ~46
         66        DO_FCALL                                      0          
   42    67        PRE_INC                                                  !4
         68    >   IS_SMALLER                                               !4, 10000
         69      > JMPNZ                                                    ~49, ->59
   46    70    >   INIT_FCALL                                               'microtime'
         71        SEND_VAL                                                 <true>
         72        DO_ICALL                                         $50     
         73        ASSIGN                                                   !6, $50
   48    74        SUB                                              ~52     !6, !3
         75        CONCAT                                           ~53     'newinstancewithoutconstructor%3A+', ~52
         76        CONCAT                                           ~54     ~53, '%3Cbr+%2F%3E'
         77        ECHO                                                     ~54
         78      > 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/oXneA
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:
147.88 ms | 1404 KiB | 15 Q