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($aBar); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, $aBar); } $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 'new keyword 2: ' . ($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 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 39
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 60
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 84
Branch analysis from position: 92
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 84
Branch analysis from position: 92
Branch analysis from position: 84
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 60
Branch analysis from position: 70
Branch analysis from position: 60
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 39
Branch analysis from position: 46
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/rvpK0
function name:  (null)
number of ops:  101
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                                                      ->44
   34    39    >   INIT_METHOD_CALL                                         !0, 'newInstanceArgs'
         40        SEND_VAR_EX                                              !3
         41        DO_FCALL                                      0  $34     
         42        ASSIGN                                                   !6, $34
   33    43        PRE_INC                                                  !5
         44    >   IS_SMALLER                                               !5, 10000
         45      > JMPNZ                                                    ~37, ->39
   36    46    >   INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $38     
         49        ASSIGN                                                   !7, $38
   38    50        SUB                                              ~40     !7, !4
         51        CONCAT                                           ~41     'newinstanceargs%3A+', ~40
         52        CONCAT                                           ~42     ~41, '%0A%0A'
         53        ECHO                                                     ~42
   41    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $43     
         57        ASSIGN                                                   !4, $43
   43    58        ASSIGN                                                   !5, 0
         59      > JMP                                                      ->68
   44    60    >   INIT_METHOD_CALL                                         !0, 'newInstanceWithoutConstructor'
         61        DO_FCALL                                      0  $46     
         62        ASSIGN                                                   !6, $46
   45    63        INIT_METHOD_CALL                                         !1, 'invokeArgs'
         64        SEND_VAR_EX                                              !6
         65        SEND_VAR_EX                                              !3
         66        DO_FCALL                                      0          
   43    67        PRE_INC                                                  !5
         68    >   IS_SMALLER                                               !5, 10000
         69      > JMPNZ                                                    ~50, ->60
   47    70    >   INIT_FCALL                                               'microtime'
         71        SEND_VAL                                                 <true>
         72        DO_ICALL                                         $51     
         73        ASSIGN                                                   !7, $51
   48    74        SUB                                              ~53     !7, !4
         75        CONCAT                                           ~54     'newinstancewithoutconstructor%3A+', ~53
         76        CONCAT                                           ~55     ~54, '%0A%0A'
         77        ECHO                                                     ~55
   51    78        INIT_FCALL                                               'microtime'
         79        SEND_VAL                                                 <true>
         80        DO_ICALL                                         $56     
         81        ASSIGN                                                   !4, $56
   53    82        ASSIGN                                                   !5, 0
         83      > JMP                                                      ->90
   54    84    >   NEW                                              $59     'Foo'
         85        SEND_UNPACK                                              !3
         86        CHECK_UNDEF_ARGS                                         
         87        DO_FCALL                                      1          
         88        ASSIGN                                                   !6, $59
   53    89        PRE_INC                                                  !5
         90    >   IS_SMALLER                                               !5, 10000
         91      > JMPNZ                                                    ~63, ->84
   56    92    >   INIT_FCALL                                               'microtime'
         93        SEND_VAL                                                 <true>
         94        DO_ICALL                                         $64     
         95        ASSIGN                                                   !7, $64
   58    96        SUB                                              ~66     !7, !4
         97        CONCAT                                           ~67     'new+keyword+2%3A+', ~66
         98        CONCAT                                           ~68     ~67, '%0A%0A'
         99        ECHO                                                     ~68
        100      > 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/rvpK0
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:
154.51 ms | 1404 KiB | 15 Q