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); amerge($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/WWlOG
function name:  (null)
number of ops:  76
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        SEND_REF                                                 !0
         54        SEND_VAR                                                 !2
         55        DO_FCALL                                      0          
   40    56        INIT_FCALL                                               'microtime'
         57        SEND_VAL                                                 <true>
         58        DO_ICALL                                         $43     
         59        ASSIGN                                                   !11, $43
   45    60        SUB                                              ~45     !5, !3
         61        MUL                                              ~46     ~45, 1000
         62        CONCAT                                           ~47     'Merging+took+', ~46
         63        CONCAT                                           ~48     ~47, '+microseconds%3Cbr+%2F%3E%0A'
         64        ECHO                                                     ~48
   46    65        SUB                                              ~49     !9, !6
         66        MUL                                              ~50     ~49, 1000
         67        CONCAT                                           ~51     'Foreach+took+', ~50
         68        CONCAT                                           ~52     ~51, '+microseconds%3Cbr+%2F%3E%0A'
         69        ECHO                                                     ~52
   47    70        SUB                                              ~53     !11, !10
         71        MUL                                              ~54     ~53, 1000
         72        CONCAT                                           ~55     'Func+took+', ~54
         73        CONCAT                                           ~56     ~55, '+microseconds%3Cbr+%2F%3E%0A'
         74        ECHO                                                     ~56
         75      > 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/WWlOG
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:
149.54 ms | 1398 KiB | 18 Q