3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iters = 500; $arr = range(0, 40_000); $t = microtime(true); foreach (range(0, $iters) as $i) { $arr = array_merge($arr, [$i => 'x']); } echo round((microtime(true) - $t) * 3, 3) . ' ms' . "\n"; $t = microtime(true); foreach (range(0, $iters) as $i) { $arr = [...$arr, $i => 'x']; } echo round((microtime(true) - $t) * 3, 3) . ' ms' . "\n"; $t = microtime(true); foreach (range(0, $iters) as $i) { $arr = [$i => 'x', ...$arr]; } echo round((microtime(true) - $t) * 3, 3) . ' ms' . "\n"; $t = microtime(true); foreach (range(0, $iters) as $i) { $arr[$i] = 'y'; } echo round((microtime(true) - $t) * 3, 3) . ' ms' . "\n"; var_dump(count($arr)); // dummy use of $arr variable
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 51
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 51
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 73, Position 2 = 78
Branch analysis from position: 73
2 jumps found. (Code = 78) Position 1 = 74, Position 2 = 78
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 78
2 jumps found. (Code = 77) Position 1 = 100, Position 2 = 104
Branch analysis from position: 100
2 jumps found. (Code = 78) Position 1 = 101, Position 2 = 104
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Branch analysis from position: 104
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 104
Branch analysis from position: 78
Branch analysis from position: 51
Branch analysis from position: 23
filename:       /in/q7YIc
function name:  (null)
number of ops:  122
compiled vars:  !0 = $iters, !1 = $arr, !2 = $t, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 500
    5     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 40000
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    7     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
    8    10        INIT_FCALL                                               'range'
         11        SEND_VAL                                                 0
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $9      
         14      > FE_RESET_R                                       $10     $9, ->23
         15    > > FE_FETCH_R                                               $10, !3, ->23
    9    16    >   INIT_FCALL                                               'array_merge'
         17        SEND_VAR                                                 !1
         18        INIT_ARRAY                                       ~11     'x', !3
         19        SEND_VAL                                                 ~11
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !1, $12
    8    22      > JMP                                                      ->15
         23    >   FE_FREE                                                  $10
   11    24        INIT_FCALL                                               'round'
         25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $14     
         28        SUB                                              ~15     $14, !2
         29        MUL                                              ~16     ~15, 3
         30        SEND_VAL                                                 ~16
         31        SEND_VAL                                                 3
         32        DO_ICALL                                         $17     
         33        CONCAT                                           ~18     $17, '+ms'
         34        CONCAT                                           ~19     ~18, '%0A'
         35        ECHO                                                     ~19
   13    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $20     
         39        ASSIGN                                                   !2, $20
   14    40        INIT_FCALL                                               'range'
         41        SEND_VAL                                                 0
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $22     
         44      > FE_RESET_R                                       $23     $22, ->51
         45    > > FE_FETCH_R                                               $23, !3, ->51
   15    46    >   INIT_ARRAY                                       ~24     
         47        ADD_ARRAY_UNPACK                                 ~24     !1
         48        ADD_ARRAY_ELEMENT                                ~24     'x', !3
         49        ASSIGN                                                   !1, ~24
   14    50      > JMP                                                      ->45
         51    >   FE_FREE                                                  $23
   17    52        INIT_FCALL                                               'round'
         53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $26     
         56        SUB                                              ~27     $26, !2
         57        MUL                                              ~28     ~27, 3
         58        SEND_VAL                                                 ~28
         59        SEND_VAL                                                 3
         60        DO_ICALL                                         $29     
         61        CONCAT                                           ~30     $29, '+ms'
         62        CONCAT                                           ~31     ~30, '%0A'
         63        ECHO                                                     ~31
   19    64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $32     
         67        ASSIGN                                                   !2, $32
   20    68        INIT_FCALL                                               'range'
         69        SEND_VAL                                                 0
         70        SEND_VAR                                                 !0
         71        DO_ICALL                                         $34     
         72      > FE_RESET_R                                       $35     $34, ->78
         73    > > FE_FETCH_R                                               $35, !3, ->78
   21    74    >   INIT_ARRAY                                       ~36     'x', !3
         75        ADD_ARRAY_UNPACK                                 ~36     !1
         76        ASSIGN                                                   !1, ~36
   20    77      > JMP                                                      ->73
         78    >   FE_FREE                                                  $35
   23    79        INIT_FCALL                                               'round'
         80        INIT_FCALL                                               'microtime'
         81        SEND_VAL                                                 <true>
         82        DO_ICALL                                         $38     
         83        SUB                                              ~39     $38, !2
         84        MUL                                              ~40     ~39, 3
         85        SEND_VAL                                                 ~40
         86        SEND_VAL                                                 3
         87        DO_ICALL                                         $41     
         88        CONCAT                                           ~42     $41, '+ms'
         89        CONCAT                                           ~43     ~42, '%0A'
         90        ECHO                                                     ~43
   25    91        INIT_FCALL                                               'microtime'
         92        SEND_VAL                                                 <true>
         93        DO_ICALL                                         $44     
         94        ASSIGN                                                   !2, $44
   26    95        INIT_FCALL                                               'range'
         96        SEND_VAL                                                 0
         97        SEND_VAR                                                 !0
         98        DO_ICALL                                         $46     
         99      > FE_RESET_R                                       $47     $46, ->104
        100    > > FE_FETCH_R                                               $47, !3, ->104
   27   101    >   ASSIGN_DIM                                               !1, !3
        102        OP_DATA                                                  'y'
   26   103      > JMP                                                      ->100
        104    >   FE_FREE                                                  $47
   29   105        INIT_FCALL                                               'round'
        106        INIT_FCALL                                               'microtime'
        107        SEND_VAL                                                 <true>
        108        DO_ICALL                                         $49     
        109        SUB                                              ~50     $49, !2
        110        MUL                                              ~51     ~50, 3
        111        SEND_VAL                                                 ~51
        112        SEND_VAL                                                 3
        113        DO_ICALL                                         $52     
        114        CONCAT                                           ~53     $52, '+ms'
        115        CONCAT                                           ~54     ~53, '%0A'
        116        ECHO                                                     ~54
   31   117        INIT_FCALL                                               'var_dump'
        118        COUNT                                            ~55     !1
        119        SEND_VAL                                                 ~55
        120        DO_ICALL                                                 
        121      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.88 ms | 1011 KiB | 18 Q