3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MemUsage{ protected $s = null; public function start(){ $this->s = memory_get_usage(); } public function get(){ return memory_get_usage()-$this->s; } } class X{ protected $v = null; public function __construct(){ $this->v = str_repeat("a", 1024*100); } } $memUsage = new MemUsage(); $memUsage->start(); $x1 = new X(); echo $memUsage->get()."\n"; //$memUsage->start(); $x2 = new X(); echo $memUsage->get()."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i8WGS
function name:  (null)
number of ops:  20
compiled vars:  !0 = $memUsage, !1 = $x1, !2 = $x2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $3      'MemUsage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   21     3        INIT_METHOD_CALL                                         !0, 'start'
          4        DO_FCALL                                      0          
   22     5        NEW                                              $7      'X'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
   23     8        INIT_METHOD_CALL                                         !0, 'get'
          9        DO_FCALL                                      0  $10     
         10        CONCAT                                           ~11     $10, '%0A'
         11        ECHO                                                     ~11
   25    12        NEW                                              $12     'X'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !2, $12
   26    15        INIT_METHOD_CALL                                         !0, 'get'
         16        DO_FCALL                                      0  $15     
         17        CONCAT                                           ~16     $15, '%0A'
         18        ECHO                                                     ~16
         19      > RETURN                                                   1

Class MemUsage:
Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i8WGS
function name:  start
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        DO_ICALL                                         $1      
          2        ASSIGN_OBJ                                               's'
          3        OP_DATA                                                  $1
    6     4      > RETURN                                                   null

End of function start

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i8WGS
function name:  get
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        DO_ICALL                                         $0      
          2        FETCH_OBJ_R                                      ~1      's'
          3        SUB                                              ~2      $0, ~1
          4      > RETURN                                                   ~2
   10     5*     > RETURN                                                   null

End of function get

End of class MemUsage.

Class X:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i8WGS
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'str_repeat'
          1        SEND_VAL                                                 'a'
          2        SEND_VAL                                                 102400
          3        DO_ICALL                                         $1      
          4        ASSIGN_OBJ                                               'v'
          5        OP_DATA                                                  $1
   17     6      > RETURN                                                   null

End of function __construct

End of class X.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.52 ms | 1400 KiB | 17 Q