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; $aBar = [$bar]; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo($bar); } $t2 = microtime(true); echo 'new keyword: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceArgs([$bar]); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, [$bar]); } $t2 = microtime(true); echo 'newinstancewithoutconstructor: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo(...$aBar); } $t2 = microtime(true); echo 'vradic: ' . ($t2-$t1) . "\n\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 18
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 39
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 61
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 92
Branch analysis from position: 92
2 jumps found. (Code = 44) Position 1 = 94, Position 2 = 86
Branch analysis from position: 94
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 94, Position 2 = 86
Branch analysis from position: 94
Branch analysis from position: 86
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 61
Branch analysis from position: 72
Branch analysis from position: 61
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 39
Branch analysis from position: 47
Branch analysis from position: 39
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 18
Branch analysis from position: 25
Branch analysis from position: 18
filename:       /in/3HL85
function name:  (null)
number of ops:  103
compiled vars:  !0 = $reflect, !1 = $constructor, !2 = $bar, !3 = $aBar, !4 = $t1, !5 = $i, !6 = $foo, !7 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $8      'ReflectionClass'
          1        SEND_VAL_EX                                              'foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $8
   16     4        INIT_METHOD_CALL                                         !0, 'getConstructor'
          5        DO_FCALL                                      0  $11     
          6        ASSIGN                                                   !1, $11
   18     7        NEW                                              $13     'Bar'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $13
   19    10        INIT_ARRAY                                       ~16     !2
         11        ASSIGN                                                   !3, ~16
   21    12        INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $18     
         15        ASSIGN                                                   !4, $18
   23    16        ASSIGN                                                   !5, 0
         17      > JMP                                                      ->23
   24    18    >   NEW                                              $21     'Foo'
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !6, $21
   23    22        PRE_INC                                                  !5
         23    >   IS_SMALLER                                               !5, 10000
         24      > JMPNZ                                                    ~25, ->18
   26    25    >   INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $26     
         28        ASSIGN                                                   !7, $26
   28    29        SUB                                              ~28     !7, !4
         30        CONCAT                                           ~29     'new+keyword%3A+', ~28
         31        CONCAT                                           ~30     ~29, '%0A%0A'
         32        ECHO                                                     ~30
   31    33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $31     
         36        ASSIGN                                                   !4, $31
   33    37        ASSIGN                                                   !5, 0
         38      > JMP                                                      ->45
   34    39    >   INIT_METHOD_CALL                                         !0, 'newInstanceArgs'
         40        INIT_ARRAY                                       ~34     !2
         41        SEND_VAL_EX                                              ~34
         42        DO_FCALL                                      0  $35     
         43        ASSIGN                                                   !6, $35
   33    44        PRE_INC                                                  !5
         45    >   IS_SMALLER                                               !5, 10000
         46      > JMPNZ                                                    ~38, ->39
   36    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $39     
         50        ASSIGN                                                   !7, $39
   38    51        SUB                                              ~41     !7, !4
         52        CONCAT                                           ~42     'newinstanceargs%3A+', ~41
         53        CONCAT                                           ~43     ~42, '%0A%0A'
         54        ECHO                                                     ~43
   41    55        INIT_FCALL                                               'microtime'
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $44     
         58        ASSIGN                                                   !4, $44
   43    59        ASSIGN                                                   !5, 0
         60      > JMP                                                      ->70
   44    61    >   INIT_METHOD_CALL                                         !0, 'newInstanceWithoutConstructor'
         62        DO_FCALL                                      0  $47     
         63        ASSIGN                                                   !6, $47
   45    64        INIT_METHOD_CALL                                         !1, 'invokeArgs'
         65        SEND_VAR_EX                                              !6
         66        INIT_ARRAY                                       ~49     !2
         67        SEND_VAL_EX                                              ~49
         68        DO_FCALL                                      0          
   43    69        PRE_INC                                                  !5
         70    >   IS_SMALLER                                               !5, 10000
         71      > JMPNZ                                                    ~52, ->61
   47    72    >   INIT_FCALL                                               'microtime'
         73        SEND_VAL                                                 <true>
         74        DO_ICALL                                         $53     
         75        ASSIGN                                                   !7, $53
   49    76        SUB                                              ~55     !7, !4
         77        CONCAT                                           ~56     'newinstancewithoutconstructor%3A+', ~55
         78        CONCAT                                           ~57     ~56, '%0A%0A'
         79        ECHO                                                     ~57
   53    80        INIT_FCALL                                               'microtime'
         81        SEND_VAL                                                 <true>
         82        DO_ICALL                                         $58     
         83        ASSIGN                                                   !4, $58
   55    84        ASSIGN                                                   !5, 0
         85      > JMP                                                      ->92
   56    86    >   NEW                                              $61     'Foo'
         87        SEND_UNPACK                                              !3
         88        CHECK_UNDEF_ARGS                                         
         89        DO_FCALL                                      1          
         90        ASSIGN                                                   !6, $61
   55    91        PRE_INC                                                  !5
         92    >   IS_SMALLER                                               !5, 10000
         93      > JMPNZ                                                    ~65, ->86
   59    94    >   INIT_FCALL                                               'microtime'
         95        SEND_VAL                                                 <true>
         96        DO_ICALL                                         $66     
         97        ASSIGN                                                   !7, $66
   61    98        SUB                                              ~68     !7, !4
         99        CONCAT                                           ~69     'vradic%3A+', ~68
        100        CONCAT                                           ~70     ~69, '%0A%0A'
        101        ECHO                                                     ~70
        102      > 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/3HL85
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:
155.48 ms | 1396 KiB | 15 Q