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) { if (array_key_exists($key, $a)) { if (is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = static::merge($a[$key], $value); } else { $a[$key] = $value; } } else { $a[$key] = $value; } } } } $startTimeFunc = microtime(true); merging::merge($classmap1, $classmap2); $endTimeFunc = microtime(true); 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
1 jumps found. (Code = 62) Position 1 = -2
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/EH4DM
function name:  (null)
number of ops:  38
compiled vars:  !0 = $classmap1, !1 = $i, !2 = $classmap2, !3 = $startTimeFunc, !4 = $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                                           ~7      'a', !1
          4        ADD                                              ~9      !1, 1
          5        ASSIGN_DIM                                               !0, ~7
          6        OP_DATA                                                  ~9
    4     7        PRE_INC                                                  !1
          8    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
          9      > JMPNZ                                                    ~11, ->3
    7    10    >   ASSIGN                                                   !2, <array>
    9    11        ASSIGN                                                   !1, 1
         12      > JMP                                                      ->18
   10    13    >   CONCAT                                           ~14     'b', !1
         14        ADD                                              ~16     !1, 1
         15        ASSIGN_DIM                                               !2, ~14
         16        OP_DATA                                                  ~16
    9    17        PRE_INC                                                  !1
         18    >   IS_SMALLER_OR_EQUAL                                      !1, 10000
         19      > JMPNZ                                                    ~18, ->13
   32    20    >   INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $19     
         23        ASSIGN                                                   !3, $19
   33    24        INIT_STATIC_METHOD_CALL                                  'merging', 'merge'
         25        SEND_REF                                                 !0
         26        SEND_REF                                                 !2
         27        DO_FCALL                                      0          
   34    28        INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !4, $22
   36    32        SUB                                              ~24     !4, !3
         33        MUL                                              ~25     ~24, 1000
         34        CONCAT                                           ~26     'Func+took+', ~25
         35        CONCAT                                           ~27     ~26, '+microseconds%3Cbr+%2F%3E%0A'
         36        ECHO                                                     ~27
   37    37      > RETURN                                                   1

Class merging:
Function merge:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 33
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 33
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 30
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 17
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/EH4DM
function name:  merge
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2      > FE_RESET_R                                       $4      !1, ->33
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->33
          4    >   ASSIGN                                                   !3, ~5
   18     5        ARRAY_KEY_EXISTS                                         !3, !0
          6      > JMPZ                                                     ~7, ->30
   19     7    >   TYPE_CHECK                                   16          !3
          8      > JMPZ                                                     ~8, ->12
   20     9    >   ASSIGN_DIM                                               !0
         10        OP_DATA                                                  !2
         11      > JMP                                                      ->29
   21    12    >   TYPE_CHECK                                  128  ~10     !2
         13      > JMPZ_EX                                          ~10     ~10, ->17
         14    >   FETCH_DIM_R                                      ~11     !0, !3
         15        TYPE_CHECK                                  128  ~12     ~11
         16        BOOL                                             ~10     ~12
         17    > > JMPZ                                                     ~10, ->27
   22    18    >   INIT_STATIC_METHOD_CALL                                  'merge'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_DIM_FUNC_ARG                               $14     !0, !3
         21        SEND_FUNC_ARG                                            $14
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0  $15     
         24        ASSIGN_DIM                                               !0, !3
         25        OP_DATA                                                  $15
         26      > JMP                                                      ->29
   24    27    >   ASSIGN_DIM                                               !0, !3
         28        OP_DATA                                                  !2
         29    > > JMP                                                      ->32
   27    30    >   ASSIGN_DIM                                               !0, !3
         31        OP_DATA                                                  !2
   17    32    > > JMP                                                      ->3
         33    >   FE_FREE                                                  $4
   30    34      > RETURN                                                   null

End of function merge

End of class merging.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.91 ms | 1396 KiB | 15 Q