3v4l.org

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

End of function amerge

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.71 ms | 1407 KiB | 18 Q