3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classmap1 = array(); for ($i=1; $i<=10000; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=10000; $i++) { $classmap2['b'.$i] = $i+1; } $startTimeMerge = microtime(true); $map = array_merge($classmap1, $classmap2); $endTimeMerge = microtime(true); $startTimeForeach = microtime(true); foreach ($classmap2 as $k => $v) { $classmap1[$k] = $v; } $endTimeForeach = microtime(true); function amerge(array $a, array $b) { foreach ($b as $key => $value) { $a[$key] = $value; } return $a; } $startTimeFunc = microtime(true); call_user_func_array('amerge', array($classmap1, $classmap2)); $endTimeFunc = microtime(true); echo "Merging took " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; echo "Foreach took " . (($endTimeForeach - $startTimeForeach)*1000) ." microseconds<br />\n"; echo "Func took " . (($endTimeFunc - $startTimeFunc)*1000) ." microseconds<br />\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 = 3
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 13
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 38, Position 2 = 43
Branch analysis from position: 38
2 jumps found. (Code = 78) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 13
Branch analysis from position: 20
Branch analysis from position: 13
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/vU67J
function name:  (null)
number of ops:  78
compiled vars:  !0 = $classmap1, !1 = $i, !2 = $classmap2, !3 = $startTimeMerge, !4 = $map, !5 = $endTimeMerge, !6 = $startTimeForeach, !7 = $v, !8 = $k, !9 = $endTimeForeach, !10 = $startTimeFunc, !11 = $endTimeFunc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->8
    5     3    >   CONCAT                                           ~14     'a', !1
          4        ADD                                              ~16     !1, 1
          5        ASSIGN_DIM                                               !0, ~14
          6        OP_DATA                                                  ~16
    4     7        PRE_INC                                                  !1
          8    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
          9      > JMPNZ                                                    ~18, ->3
    7    10    >   ASSIGN                                                   !2, <array>
    9    11        ASSIGN                                                   !1, 1
         12      > JMP                                                      ->18
   10    13    >   CONCAT                                           ~21     'b', !1
         14        ADD                                              ~23     !1, 1
         15        ASSIGN_DIM                                               !2, ~21
         16        OP_DATA                                                  ~23
    9    17        PRE_INC                                                  !1
         18    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
         19      > JMPNZ                                                    ~25, ->13
   14    20    >   INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $26     
         23        ASSIGN                                                   !3, $26
   15    24        INIT_FCALL                                               'array_merge'
         25        SEND_VAR                                                 !0
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $28     
         28        ASSIGN                                                   !4, $28
   16    29        INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $30     
         32        ASSIGN                                                   !5, $30
   18    33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $32     
         36        ASSIGN                                                   !6, $32
   19    37      > FE_RESET_R                                       $34     !2, ->43
         38    > > FE_FETCH_R                                       ~35     $34, !7, ->43
         39    >   ASSIGN                                                   !8, ~35
   20    40        ASSIGN_DIM                                               !0, !8
         41        OP_DATA                                                  !7
   19    42      > JMP                                                      ->38
         43    >   FE_FREE                                                  $34
   22    44        INIT_FCALL                                               'microtime'
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $38     
         47        ASSIGN                                                   !9, $38
   38    48        INIT_FCALL                                               'microtime'
         49        SEND_VAL                                                 <true>
         50        DO_ICALL                                         $40     
         51        ASSIGN                                                   !10, $40
   39    52        INIT_FCALL                                               'amerge'
         53        INIT_ARRAY                                       ~42     !0
         54        ADD_ARRAY_ELEMENT                                ~42     !2
         55        SEND_ARRAY                                               ~42
         56        CHECK_UNDEF_ARGS                                         
         57        DO_FCALL                                      0          
   40    58        INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $44     
         61        ASSIGN                                                   !11, $44
   45    62        SUB                                              ~46     !5, !3
         63        MUL                                              ~47     ~46, 1000
         64        CONCAT                                           ~48     'Merging+took+', ~47
         65        CONCAT                                           ~49     ~48, '+microseconds%3Cbr+%2F%3E%0A'
         66        ECHO                                                     ~49
   46    67        SUB                                              ~50     !9, !6
         68        MUL                                              ~51     ~50, 1000
         69        CONCAT                                           ~52     'Foreach+took+', ~51
         70        CONCAT                                           ~53     ~52, '+microseconds%3Cbr+%2F%3E%0A'
         71        ECHO                                                     ~53
   47    72        SUB                                              ~54     !11, !10
         73        MUL                                              ~55     ~54, 1000
         74        CONCAT                                           ~56     'Func+took+', ~55
         75        CONCAT                                           ~57     ~56, '+microseconds%3Cbr+%2F%3E%0A'
         76        ECHO                                                     ~57
         77      > RETURN                                                   1

Function amerge:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/vU67J
function name:  amerge
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2      > FE_RESET_R                                       $4      !1, ->8
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->8
          4    >   ASSIGN                                                   !3, ~5
   31     5        ASSIGN_DIM                                               !0, !3
          6        OP_DATA                                                  !2
   29     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $4
   34     9      > RETURN                                                   !0
   35    10*     > RETURN                                                   null

End of function amerge

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.68 ms | 1407 KiB | 18 Q