3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar() { return ""; } } $ts = microtime(true); for ($i=1; $i<=10000; $i++) { $c = new Foo(); echo $c->bar(); unset ($c); } $tt = microtime(true); $t1 = $tt-$ts; unset($ts, $tt); echo "Variable Instantiation takes {$t1} seconds\n"; $ts = microtime(true); for ($i=1; $i<=10000; $i++) { echo (new Foo())->bar(); } $tt = microtime(true); $t2 = $tt-$ts; unset($ts, $tt); echo "Magic Instantiation takes {$t2} seconds\n"; echo "\n"; if ($t1 < $t2) { echo "Variable Instantion is faster by a factor of ".(($t2*100)/$t1)."\n"; } else { echo "Magic Instantion is faster by a factor of ".(($t1*100)/$t2)."\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 6
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 34
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 34
Branch analysis from position: 42
Branch analysis from position: 34
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 6
Branch analysis from position: 16
Branch analysis from position: 6
filename:       /in/sa2QT
function name:  (null)
number of ops:  69
compiled vars:  !0 = $ts, !1 = $i, !2 = $c, !3 = $tt, !4 = $t1, !5 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
    9     4        ASSIGN                                                   !1, 1
          5      > JMP                                                      ->14
   10     6    >   NEW                                              $9      'Foo'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   11     9        INIT_METHOD_CALL                                         !2, 'bar'
         10        DO_FCALL                                      0  $12     
         11        ECHO                                                     $12
   12    12        UNSET_CV                                                 !2
    9    13        PRE_INC                                                  !1
         14    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
         15      > JMPNZ                                                    ~14, ->6
   14    16    >   INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $15     
         19        ASSIGN                                                   !3, $15
   15    20        SUB                                              ~17     !3, !0
         21        ASSIGN                                                   !4, ~17
   16    22        UNSET_CV                                                 !0
         23        UNSET_CV                                                 !3
   18    24        ROPE_INIT                                     3  ~20     'Variable+Instantiation+takes+'
         25        ROPE_ADD                                      1  ~20     ~20, !4
         26        ROPE_END                                      2  ~19     ~20, '+seconds%0A'
         27        ECHO                                                     ~19
   20    28        INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !0, $22
   21    32        ASSIGN                                                   !1, 1
         33      > JMP                                                      ->40
   22    34    >   NEW                                              $25     'Foo'
         35        DO_FCALL                                      0          
         36        INIT_METHOD_CALL                                         $25, 'bar'
         37        DO_FCALL                                      0  $27     
         38        ECHO                                                     $27
   21    39        PRE_INC                                                  !1
         40    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
         41      > JMPNZ                                                    ~29, ->34
   24    42    >   INIT_FCALL                                               'microtime'
         43        SEND_VAL                                                 <true>
         44        DO_ICALL                                         $30     
         45        ASSIGN                                                   !3, $30
   25    46        SUB                                              ~32     !3, !0
         47        ASSIGN                                                   !5, ~32
   26    48        UNSET_CV                                                 !0
         49        UNSET_CV                                                 !3
   28    50        ROPE_INIT                                     3  ~35     'Magic+Instantiation+takes+'
         51        ROPE_ADD                                      1  ~35     ~35, !5
         52        ROPE_END                                      2  ~34     ~35, '+seconds%0A'
         53        ECHO                                                     ~34
   29    54        ECHO                                                     '%0A'
   30    55        IS_SMALLER                                               !4, !5
         56      > JMPZ                                                     ~37, ->63
   31    57    >   MUL                                              ~38     !5, 100
         58        DIV                                              ~39     ~38, !4
         59        CONCAT                                           ~40     'Variable+Instantion+is+faster+by+a+factor+of+', ~39
         60        CONCAT                                           ~41     ~40, '%0A'
         61        ECHO                                                     ~41
         62      > JMP                                                      ->68
   33    63    >   MUL                                              ~42     !4, 100
         64        DIV                                              ~43     ~42, !5
         65        CONCAT                                           ~44     'Magic+Instantion+is+faster+by+a+factor+of+', ~43
         66        CONCAT                                           ~45     ~44, '%0A'
         67        ECHO                                                     ~45
   34    68    > > RETURN                                                   1

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

End of function bar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.47 ms | 1400 KiB | 15 Q