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; } abstract class merging { public static function merge(array &$a, array &$b) { foreach ($b as $key => $value) { $a[$key] = $value; } return $a; } } $startTimeFunc = microtime(true); merging::merge($classmap1, $classmap2); $endTimeFunc = microtime(true); $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); 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 = 50, Position 2 = 55
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
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/FDtd6
function name:  (null)
number of ops:  76
compiled vars:  !0 = $classmap1, !1 = $i, !2 = $classmap2, !3 = $startTimeFunc, !4 = $endTimeFunc, !5 = $startTimeMerge, !6 = $map, !7 = $endTimeMerge, !8 = $startTimeForeach, !9 = $v, !10 = $k, !11 = $endTimeForeach
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
   22    20    >   INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $26     
         23        ASSIGN                                                   !3, $26
   23    24        INIT_STATIC_METHOD_CALL                                  'merging', 'merge'
         25        SEND_REF                                                 !0
         26        SEND_REF                                                 !2
         27        DO_FCALL                                      0          
   24    28        INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $29     
         31        ASSIGN                                                   !4, $29
   26    32        INIT_FCALL                                               'microtime'
         33        SEND_VAL                                                 <true>
         34        DO_ICALL                                         $31     
         35        ASSIGN                                                   !5, $31
   27    36        INIT_FCALL                                               'array_merge'
         37        SEND_VAR                                                 !0
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                         $33     
         40        ASSIGN                                                   !6, $33
   28    41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $35     
         44        ASSIGN                                                   !7, $35
   30    45        INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $37     
         48        ASSIGN                                                   !8, $37
   31    49      > FE_RESET_R                                       $39     !2, ->55
         50    > > FE_FETCH_R                                       ~40     $39, !9, ->55
         51    >   ASSIGN                                                   !10, ~40
   32    52        ASSIGN_DIM                                               !0, !10
         53        OP_DATA                                                  !9
   31    54      > JMP                                                      ->50
         55    >   FE_FREE                                                  $39
   34    56        INIT_FCALL                                               'microtime'
         57        SEND_VAL                                                 <true>
         58        DO_ICALL                                         $43     
         59        ASSIGN                                                   !11, $43
   38    60        SUB                                              ~45     !7, !5
         61        MUL                                              ~46     ~45, 1000
         62        CONCAT                                           ~47     'Merging+took+', ~46
         63        CONCAT                                           ~48     ~47, '+microseconds%3Cbr+%2F%3E%0A'
         64        ECHO                                                     ~48
   40    65        SUB                                              ~49     !11, !8
         66        MUL                                              ~50     ~49, 1000
         67        CONCAT                                           ~51     'Foreach+took+', ~50
         68        CONCAT                                           ~52     ~51, '+microseconds%3Cbr+%2F%3E%0A'
         69        ECHO                                                     ~52
   42    70        SUB                                              ~53     !4, !3
         71        MUL                                              ~54     ~53, 1000
         72        CONCAT                                           ~55     'Func+took+', ~54
         73        CONCAT                                           ~56     ~55, '+microseconds%3Cbr+%2F%3E%0A'
         74        ECHO                                                     ~56
   43    75      > RETURN                                                   1

Class merging:
Function merge:
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/FDtd6
function name:  merge
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2      > FE_RESET_R                                       $4      !1, ->8
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->8
          4    >   ASSIGN                                                   !3, ~5
   17     5        ASSIGN_DIM                                               !0, !3
          6        OP_DATA                                                  !2
   16     7      > JMP                                                      ->3
          8    >   FE_FREE                                                  $4
   19     9      > RETURN                                                   !0
   20    10*     > RETURN                                                   null

End of function merge

End of class merging.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.01 ms | 1404 KiB | 17 Q