3v4l.org

run code in 500+ PHP versions simultaneously
<?php class LargeObject { protected $array; public function __construct() { $this->array = array_fill(0, 2000, 17); } public function getItemProcessor(): Closure { // Try with and without 'static' here return function () { // do some processing unrelated to $this }; } } $start = microtime(true); $processors = []; for ($i = 0; $i < 2000; $i++) { $lo = new LargeObject(); $processors[] = $lo->getItemProcessor(); } $memory = memory_get_usage() >> 20; $time = (microtime(true) - $start) * 1000; printf("This took %dms and %dMB of memory\n", $time, $memory);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
Branch analysis from position: 7
filename:       /in/QnDuA
function name:  (null)
number of ops:  33
compiled vars:  !0 = $start, !1 = $processors, !2 = $i, !3 = $lo, !4 = $memory, !5 = $time
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                                   'microtime'
          1        SEND_VAL                                                     <true>
          2        DO_ICALL                                             $6      
          3        ASSIGN                                                       !0, $6
   20     4        ASSIGN                                                       !1, <array>
   21     5        ASSIGN                                                       !2, 0
          6      > JMP                                                          ->15
   22     7    >   NEW                                                  $10     'LargeObject'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !3, $10
   23    10        INIT_METHOD_CALL                                             !3, 'getItemProcessor'
         11        DO_FCALL                                          0  $14     
         12        ASSIGN_DIM                                                   !1
         13        OP_DATA                                                      $14
   21    14        PRE_INC                                                      !2
         15    >   IS_SMALLER                                                   !2, 2000
         16      > JMPNZ                                                        ~16, ->7
   26    17    >   INIT_FCALL                                                   'memory_get_usage'
         18        DO_ICALL                                             $17     
         19        SR                                                   ~18     $17, 20
         20        ASSIGN                                                       !4, ~18
   27    21        INIT_FCALL                                                   'microtime'
         22        SEND_VAL                                                     <true>
         23        DO_ICALL                                             $20     
         24        SUB                                                  ~21     $20, !0
         25        MUL                                                  ~22     ~21, 1000
         26        ASSIGN                                                       !5, ~22
   28    27        INIT_FCALL                                                   'printf'
         28        SEND_VAL                                                     'This+took+%25dms+and+%25dMB+of+memory%0A'
         29        SEND_VAR                                                     !5
         30        SEND_VAR                                                     !4
         31        DO_ICALL                                                     
         32      > RETURN                                                       1

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

End of function __construct

Function getitemprocessor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QnDuA
function name:  getItemProcessor
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   DECLARE_LAMBDA_FUNCTION                              ~0      [0]
   14     1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   15     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QnDuA
function name:  {closure:LargeObject::getItemProcessor():12}
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                       null

End of Dynamic Function 0

End of function getitemprocessor

End of class LargeObject.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.04 ms | 1992 KiB | 17 Q