3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Model { public function get() {} } class Foo { protected $model; public function __construct() { $this->model = new Model; } public function doSomethingGetModelOnce() { $model = $this->getModel(); for ($i = 0; $i < 10000; $i++) { $model->get(); } } public function doSomethingGetModelNTimes() { for ($i = 0; $i < 10000; $i++) { $this->getModel()->get(); } } protected function getModel() { return $this->model; } } $foo = new Foo(); $time0 = microtime(true); $foo->doSomethingGetModelOnce(); $time1 = microtime(true); $foo->doSomethingGetModelNTimes(); $time2 = microtime(true); var_dump(1000*($time1-$time0), 1000*($time2-$time1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jd3BD
function name:  (null)
number of ops:  28
compiled vars:  !0 = $foo, !1 = $time0, !2 = $time1, !3 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $4      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   43     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   44     7        INIT_METHOD_CALL                                         !0, 'doSomethingGetModelOnce'
          8        DO_FCALL                                      0          
   45     9        INIT_FCALL                                               'microtime'
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !2, $10
   46    13        INIT_METHOD_CALL                                         !0, 'doSomethingGetModelNTimes'
         14        DO_FCALL                                      0          
   47    15        INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !3, $13
   49    19        INIT_FCALL                                               'var_dump'
         20        SUB                                              ~15     !2, !1
         21        MUL                                              ~16     ~15, 1000
         22        SEND_VAL                                                 ~16
         23        SUB                                              ~17     !3, !2
         24        MUL                                              ~18     ~17, 1000
         25        SEND_VAL                                                 ~18
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

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

End of function get

End of class Model.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jd3BD
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $1      'Model'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'model'
          3        OP_DATA                                                  $1
   15     4      > RETURN                                                   null

End of function __construct

Function dosomethinggetmodelonce:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
Branch analysis from position: 5
filename:       /in/jd3BD
function name:  doSomethingGetModelOnce
number of ops:  11
compiled vars:  !0 = $model, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_METHOD_CALL                                         'getModel'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   21     3        ASSIGN                                                   !1, 0
          4      > JMP                                                      ->8
   22     5    >   INIT_METHOD_CALL                                         !0, 'get'
          6        DO_FCALL                                      0          
   21     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 10000
          9      > JMPNZ                                                    ~7, ->5
   24    10    > > RETURN                                                   null

End of function dosomethinggetmodelonce

Function dosomethinggetmodelntimes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
Branch analysis from position: 2
filename:       /in/jd3BD
function name:  doSomethingGetModelNTimes
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->7
   29     2    >   INIT_METHOD_CALL                                         'getModel'
          3        DO_FCALL                                      0  $2      
          4        INIT_METHOD_CALL                                         $2, 'get'
          5        DO_FCALL                                      0          
   28     6        PRE_INC                                                  !0
          7    >   IS_SMALLER                                               !0, 10000
          8      > JMPNZ                                                    ~5, ->2
   31     9    > > RETURN                                                   null

End of function dosomethinggetmodelntimes

Function getmodel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jd3BD
function name:  getModel
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~0      'model'
          1      > RETURN                                                   ~0
   36     2*     > RETURN                                                   null

End of function getmodel

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.78 ms | 1392 KiB | 17 Q