3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MenuLinkTreeElement { public $link; public $subtree; public $depth; public $hasChildren; public $inActiveTrail; public $access; public $options; public function __construct($link, $has_children, $depth, $in_active_trail, array $subtree) { $this->link = $link; $this->hasChildren = $has_children; $this->depth = $depth; $this->subtree = $subtree; $this->inActiveTrail = $in_active_trail; $this->access = NULL; $this->options = array(); } public function count() { $sum = function ($carry, MenuLinkTreeElement $element) { return $carry + $element->count(); }; return 1 + array_reduce($this->subtree, $sum); } } $array_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = array( 'link' => new StdClass(), 'has_children' => TRUE, 'depth' => 3, 'in_active_trail' => FALSE, 'below' => array(), 'access' => NULL, 'options' => array(), ); } $array_time = microtime(TRUE) - $array_start; $object_start = microtime(TRUE); $storage = array(); for ($i = 0; $i < 1000; $i++) { $storage[] = new MenuLinkTreeElement(new StdClass(), TRUE, 3, FALSE, array()); } $object_time = microtime(TRUE) - $object_start; echo 'arrays: ' . number_format($array_time, 3) . " s\n"; echo 'objects: ' . number_format($object_time, 3) . " s\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 33
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 33
Branch analysis from position: 47
Branch analysis from position: 33
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
Branch analysis from position: 7
filename:       /in/lSaKc
function name:  (null)
number of ops:  67
compiled vars:  !0 = $array_start, !1 = $storage, !2 = $i, !3 = $array_time, !4 = $object_start, !5 = $object_time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
   33     4        ASSIGN                                                   !1, <array>
   34     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->19
   36     7    >   NEW                                              $11     'StdClass'
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~13     $11, 'link'
         10        ADD_ARRAY_ELEMENT                                ~13     <true>, 'has_children'
   38    11        ADD_ARRAY_ELEMENT                                ~13     3, 'depth'
   36    12        ADD_ARRAY_ELEMENT                                ~13     <false>, 'in_active_trail'
         13        ADD_ARRAY_ELEMENT                                ~13     <array>, 'below'
         14        ADD_ARRAY_ELEMENT                                ~13     null, 'access'
         15        ADD_ARRAY_ELEMENT                                ~13     <array>, 'options'
   35    16        ASSIGN_DIM                                               !1
   36    17        OP_DATA                                                  ~13
   34    18        PRE_INC                                                  !2
         19    >   IS_SMALLER                                               !2, 1000
         20      > JMPNZ                                                    ~15, ->7
   45    21    >   INIT_FCALL                                               'microtime'
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $16     
         24        SUB                                              ~17     $16, !0
         25        ASSIGN                                                   !3, ~17
   48    26        INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $19     
         29        ASSIGN                                                   !4, $19
   49    30        ASSIGN                                                   !1, <array>
   50    31        ASSIGN                                                   !2, 0
         32      > JMP                                                      ->45
   51    33    >   NEW                                              $24     'MenuLinkTreeElement'
         34        NEW                                              $25     'StdClass'
         35        DO_FCALL                                      0          
         36        SEND_VAR_NO_REF_EX                                       $25
         37        SEND_VAL_EX                                              <true>
         38        SEND_VAL_EX                                              3
         39        SEND_VAL_EX                                              <false>
         40        SEND_VAL_EX                                              <array>
         41        DO_FCALL                                      0          
         42        ASSIGN_DIM                                               !1
         43        OP_DATA                                                  $24
   50    44        PRE_INC                                                  !2
         45    >   IS_SMALLER                                               !2, 1000
         46      > JMPNZ                                                    ~29, ->33
   53    47    >   INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $30     
         50        SUB                                              ~31     $30, !4
         51        ASSIGN                                                   !5, ~31
   55    52        INIT_FCALL                                               'number_format'
         53        SEND_VAR                                                 !3
         54        SEND_VAL                                                 3
         55        DO_ICALL                                         $33     
         56        CONCAT                                           ~34     'arrays%3A+', $33
         57        CONCAT                                           ~35     ~34, '+s%0A'
         58        ECHO                                                     ~35
   56    59        INIT_FCALL                                               'number_format'
         60        SEND_VAR                                                 !5
         61        SEND_VAL                                                 3
         62        DO_ICALL                                         $36     
         63        CONCAT                                           ~37     'objects%3A+', $36
         64        CONCAT                                           ~38     ~37, '+s%0A'
         65        ECHO                                                     ~38
         66      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FlSaKc%3A24%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSaKc
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $carry, !1 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        INIT_METHOD_CALL                                         !1, 'count'
          3        DO_FCALL                                      0  $2      
          4        ADD                                              ~3      !0, $2
          5      > RETURN                                                   ~3
   26     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FlSaKc%3A24%240

Class MenuLinkTreeElement:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSaKc
function name:  __construct
number of ops:  20
compiled vars:  !0 = $link, !1 = $has_children, !2 = $depth, !3 = $in_active_trail, !4 = $subtree
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   14     5        ASSIGN_OBJ                                               'link'
          6        OP_DATA                                                  !0
   15     7        ASSIGN_OBJ                                               'hasChildren'
          8        OP_DATA                                                  !1
   16     9        ASSIGN_OBJ                                               'depth'
         10        OP_DATA                                                  !2
   17    11        ASSIGN_OBJ                                               'subtree'
         12        OP_DATA                                                  !4
   18    13        ASSIGN_OBJ                                               'inActiveTrail'
         14        OP_DATA                                                  !3
   19    15        ASSIGN_OBJ                                               'access'
         16        OP_DATA                                                  null
   20    17        ASSIGN_OBJ                                               'options'
         18        OP_DATA                                                  <array>
   21    19      > RETURN                                                   null

End of function __construct

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSaKc
function name:  count
number of ops:  10
compiled vars:  !0 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FlSaKc%3A24%240'
          1        ASSIGN                                                   !0, ~1
   27     2        INIT_FCALL                                               'array_reduce'
          3        FETCH_OBJ_R                                      ~3      'subtree'
          4        SEND_VAL                                                 ~3
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ADD                                              ~5      1, $4
          8      > RETURN                                                   ~5
   28     9*     > RETURN                                                   null

End of function count

End of class MenuLinkTreeElement.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.35 ms | 1404 KiB | 19 Q