3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } class obj { public $items = array(); public $data; } function subobj($obj, $depth=5) { for($i = 0; $i < 5; $i++) { $obj->items[$i] = new obj; $obj->items[$i]->data = generateRandomString(64); if($depth>1) subobj($obj->items[$i], $depth-1); } } print "Populating object..."; $obj = new obj; for($i = 0; $i < 10; $i++) { subobj($obj); } print "\nSerializing..."; $data = serialize($obj); print "\nLooping...\n"; $iterations = 20000; while($iterations--) { $newstr = unserialize($data); if($iterations % 1000 == 0) print "$iterations: " . sprintf('%0.2f', memory_get_usage()/1024/1024) . "Mb\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 20
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 40
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 20
Branch analysis from position: 42
Branch analysis from position: 20
Branch analysis from position: 40
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
Branch analysis from position: 6
filename:       /in/2fY9M
function name:  (null)
number of ops:  43
compiled vars:  !0 = $obj, !1 = $i, !2 = $data, !3 = $iterations, !4 = $newstr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     'Populating+object...'
   24     1        NEW                                              $5      'obj'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $5
   25     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->10
   26     6    >   INIT_FCALL                                               'subobj'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0          
   25     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 10
         11      > JMPNZ                                                    ~11, ->6
   28    12    >   ECHO                                                     '%0ASerializing...'
   30    13        INIT_FCALL                                               'serialize'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !2, $12
   32    17        ECHO                                                     '%0ALooping...%0A'
   33    18        ASSIGN                                                   !3, 20000
   34    19      > JMP                                                      ->40
   35    20    >   INIT_FCALL                                               'unserialize'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        ASSIGN                                                   !4, $15
   36    24        MOD                                              ~17     !3, 1000
         25        IS_EQUAL                                                 ~17, 0
         26      > JMPZ                                                     ~18, ->40
   37    27    >   NOP                                                      
         28        FAST_CONCAT                                      ~19     !3, '%3A+'
         29        INIT_FCALL                                               'sprintf'
         30        SEND_VAL                                                 '%250.2f'
         31        INIT_FCALL                                               'memory_get_usage'
         32        DO_ICALL                                         $20     
         33        DIV                                              ~21     $20, 1024
         34        DIV                                              ~22     ~21, 1024
         35        SEND_VAL                                                 ~22
         36        DO_ICALL                                         $23     
         37        CONCAT                                           ~24     ~19, $23
         38        CONCAT                                           ~25     ~24, 'Mb%0A'
         39        ECHO                                                     ~25
   34    40    >   POST_DEC                                         ~26     !3
         41      > JMPNZ                                                    ~26, ->20
   38    42    > > RETURN                                                   1

Function generaterandomstring:
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 = 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
Branch analysis from position: 5
filename:       /in/2fY9M
function name:  generateRandomString
number of ops:  18
compiled vars:  !0 = $length, !1 = $characters, !2 = $randomString, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      10
    4     1        ASSIGN                                                   !1, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    5     2        ASSIGN                                                   !2, ''
    6     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->14
          5    >   INIT_FCALL                                               'rand'
          6        SEND_VAL                                                 0
          7        STRLEN                                           ~7      !1
          8        SUB                                              ~8      ~7, 1
          9        SEND_VAL                                                 ~8
         10        DO_ICALL                                         $9      
         11        FETCH_DIM_R                                      ~10     !1, $9
         12        ASSIGN_OP                                     8          !2, ~10
         13        PRE_INC                                                  !3
         14    >   IS_SMALLER                                               !3, !0
         15      > JMPNZ                                                    ~13, ->5
    7    16    > > RETURN                                                   !2
    8    17*     > RETURN                                                   null

End of function generaterandomstring

Function subobj:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 4
Branch analysis from position: 29
Branch analysis from position: 4
Branch analysis from position: 26
filename:       /in/2fY9M
function name:  subobj
number of ops:  30
compiled vars:  !0 = $obj, !1 = $depth, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      5
   16     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->27
   17     4    >   NEW                                              $6      'obj'
          5        DO_FCALL                                      0          
          6        FETCH_OBJ_W                                      $4      !0, 'items'
          7        ASSIGN_DIM                                               $4, !2
          8        OP_DATA                                                  $6
   18     9        INIT_FCALL                                               'generaterandomstring'
         10        SEND_VAL                                                 64
         11        DO_FCALL                                      0  $11     
         12        FETCH_OBJ_W                                      $8      !0, 'items'
         13        FETCH_DIM_W                                      $9      $8, !2
         14        ASSIGN_OBJ                                               $9, 'data'
         15        OP_DATA                                                  $11
   19    16        IS_SMALLER                                               1, !1
         17      > JMPZ                                                     ~12, ->26
         18    >   INIT_FCALL_BY_NAME                                       'subobj'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_FUNC_ARG                               $13     !0, 'items'
         21        FETCH_DIM_FUNC_ARG                               $14     $13, !2
         22        SEND_FUNC_ARG                                            $14
         23        SUB                                              ~15     !1, 1
         24        SEND_VAL_EX                                              ~15
         25        DO_FCALL                                      0          
   16    26    >   PRE_INC                                                  !2
         27    >   IS_SMALLER                                               !2, 5
         28      > JMPNZ                                                    ~18, ->4
   21    29    > > RETURN                                                   null

End of function subobj

Class obj: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.24 ms | 1411 KiB | 25 Q