3v4l.org

run code in 300+ PHP versions simultaneously
<?php // test one.. // start time $st = microtime(); function arr1(){ $arr1 = array(); $arr2 = array(); $arr3 = array(); $arr1['key1'] = 'val1'; $arr2['key1'] = 'val1'; $arr3['key1'] = 'val1'; return array($arr1, $arr2, $arr3); } $i = 1000; while($i--){ $poo = arr1(); } echo "Method 1: created 1000 arrays in " . (microtime() - $st) . " microseconds...\n"; // test two.. // start time $st = microtime(); function arr2(){ $arr1 = array(); $arr1['arr1']['key1'] = 'val1'; $arr1['arr2']['key1'] = 'val1'; $arr1['arr3']['key1'] = 'val1'; return array($arr1); } $i = 1000; while($i--){ $poo = arr2(); } echo "Method 2: created 1000 arrays in " . (microtime() - $st) . " microseconds...\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 21
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 21
Branch analysis from position: 26
Branch analysis from position: 21
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
Branch analysis from position: 5
filename:       /in/3oudf
function name:  (null)
number of ops:  33
compiled vars:  !0 = $st, !1 = $i, !2 = $poo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'microtime'
          1        DO_ICALL                                         $3      
          2        ASSIGN                                                   !0, $3
   20     3        ASSIGN                                                   !1, 1000
   21     4      > JMP                                                      ->8
   22     5    >   INIT_FCALL                                               'arr1'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   21     8    >   POST_DEC                                         ~8      !1
          9      > JMPNZ                                                    ~8, ->5
   26    10    >   INIT_FCALL                                               'microtime'
         11        DO_ICALL                                         $9      
         12        SUB                                              ~10     $9, !0
         13        CONCAT                                           ~11     'Method+1%3A+created+1000+arrays+in+', ~10
         14        CONCAT                                           ~12     ~11, '+microseconds...%0A'
         15        ECHO                                                     ~12
   31    16        INIT_FCALL                                               'microtime'
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !0, $13
   43    19        ASSIGN                                                   !1, 1000
   44    20      > JMP                                                      ->24
   45    21    >   INIT_FCALL                                               'arr2'
         22        DO_FCALL                                      0  $16     
         23        ASSIGN                                                   !2, $16
   44    24    >   POST_DEC                                         ~18     !1
         25      > JMPNZ                                                    ~18, ->21
   49    26    >   INIT_FCALL                                               'microtime'
         27        DO_ICALL                                         $19     
         28        SUB                                              ~20     $19, !0
         29        CONCAT                                           ~21     'Method+2%3A+created+1000+arrays+in+', ~20
         30        CONCAT                                           ~22     ~21, '+microseconds...%0A'
         31        ECHO                                                     ~22
         32      > RETURN                                                   1

Function arr1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3oudf
function name:  arr1
number of ops:  14
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $arr3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2        ASSIGN                                                   !2, <array>
   13     3        ASSIGN_DIM                                               !0, 'key1'
          4        OP_DATA                                                  'val1'
   14     5        ASSIGN_DIM                                               !1, 'key1'
          6        OP_DATA                                                  'val1'
   15     7        ASSIGN_DIM                                               !2, 'key1'
          8        OP_DATA                                                  'val1'
   17     9        INIT_ARRAY                                       ~9      !0
         10        ADD_ARRAY_ELEMENT                                ~9      !1
         11        ADD_ARRAY_ELEMENT                                ~9      !2
         12      > RETURN                                                   ~9
   18    13*     > RETURN                                                   null

End of function arr1

Function arr2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3oudf
function name:  arr2
number of ops:  13
compiled vars:  !0 = $arr1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   ASSIGN                                                   !0, <array>
   36     1        FETCH_DIM_W                                      $2      !0, 'arr1'
          2        ASSIGN_DIM                                               $2, 'key1'
          3        OP_DATA                                                  'val1'
   37     4        FETCH_DIM_W                                      $4      !0, 'arr2'
          5        ASSIGN_DIM                                               $4, 'key1'
          6        OP_DATA                                                  'val1'
   38     7        FETCH_DIM_W                                      $6      !0, 'arr3'
          8        ASSIGN_DIM                                               $6, 'key1'
          9        OP_DATA                                                  'val1'
   40    10        INIT_ARRAY                                       ~8      !0
         11      > RETURN                                                   ~8
   41    12*     > RETURN                                                   null

End of function arr2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.98 ms | 1403 KiB | 17 Q