3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = []; /* record T(int $x, int $y); */ readonly class T { public function __construct(public int $x, public int $y) {}} // emulate a record $t = new T(1,2); for($x = 0; $x <= 100_000; $x++) $arr[] = $t /* &T(1,2) */ ; echo "Current memory usage: " . (memory_get_usage() / 1024) . " KB\n"; echo "Peak memory usage: " . (memory_get_peak_usage() / 1024) . " KB\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Branch analysis from position: 8
filename:       /in/4nYXG
function name:  (null)
number of ops:  26
compiled vars:  !0 = $arr, !1 = $t, !2 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        NEW                                                  $4      'T'
          2        SEND_VAL_EX                                                  1
          3        SEND_VAL_EX                                                  2
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $4
   11     6        ASSIGN                                                       !2, 0
          7      > JMP                                                          ->11
          8    >   ASSIGN_DIM                                                   !0
          9        OP_DATA                                                      !1
         10        PRE_INC                                                      !2
         11    >   IS_SMALLER_OR_EQUAL                                          !2, 100000
         12      > JMPNZ                                                        ~10, ->8
   13    13    >   INIT_FCALL                                                   'memory_get_usage'
         14        DO_ICALL                                             $11     
         15        DIV                                                  ~12     $11, 1024
         16        CONCAT                                               ~13     'Current+memory+usage%3A+', ~12
         17        CONCAT                                               ~14     ~13, '+KB%0A'
         18        ECHO                                                         ~14
   14    19        INIT_FCALL                                                   'memory_get_peak_usage'
         20        DO_ICALL                                             $15     
         21        DIV                                                  ~16     $15, 1024
         22        CONCAT                                               ~17     'Peak+memory+usage%3A+', ~16
         23        CONCAT                                               ~18     ~17, '+KB%0A'
         24        ECHO                                                         ~18
         25      > RETURN                                                       1

Class T:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4nYXG
function name:  __construct
number of ops:  7
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        ASSIGN_OBJ                                                   'x'
          3        OP_DATA                                                      !0
          4        ASSIGN_OBJ                                                   'y'
          5        OP_DATA                                                      !1
          6      > RETURN                                                       null

End of function __construct

End of class T.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.27 ms | 1398 KiB | 15 Q