3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classmap1 = array(); for ($i=1; $i<=5000; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=5000; $i++) { $classmap2['b'.$i] = $i+1; } abstract class merging { public static function merge(array $a, array &$b) { foreach ($b as $key => $value) { if (isset($a[$key]) || 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; } } return $a; } } $startTimeFunc = microtime(true); merging::merge($classmap1, $classmap2); $endTimeFunc = microtime(true); 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
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/pglkZ
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, 5000
          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, 5000
         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_VAR                                                 !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      > RETURN                                                   1

Class merging:
Function merge:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 36
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 36
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 33
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 20
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/pglkZ
function name:  merge
number of ops:  39
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, ->36
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->36
          4    >   ASSIGN                                                   !3, ~5
   17     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !0, !3
          6      > JMPNZ_EX                                         ~7      ~7, ->9
          7    >   ARRAY_KEY_EXISTS                                 ~8      !3, !0
          8        BOOL                                             ~7      ~8
          9    > > JMPZ                                                     ~7, ->33
   18    10    >   TYPE_CHECK                                   16          !3
         11      > JMPZ                                                     ~9, ->15
   19    12    >   ASSIGN_DIM                                               !0
         13        OP_DATA                                                  !2
         14      > JMP                                                      ->32
   20    15    >   TYPE_CHECK                                  128  ~11     !2
         16      > JMPZ_EX                                          ~11     ~11, ->20
         17    >   FETCH_DIM_R                                      ~12     !0, !3
         18        TYPE_CHECK                                  128  ~13     ~12
         19        BOOL                                             ~11     ~13
         20    > > JMPZ                                                     ~11, ->30
   21    21    >   INIT_STATIC_METHOD_CALL                                  'merge'
         22        CHECK_FUNC_ARG                                           
         23        FETCH_DIM_FUNC_ARG                               $15     !0, !3
         24        SEND_FUNC_ARG                                            $15
         25        SEND_VAR_EX                                              !2
         26        DO_FCALL                                      0  $16     
         27        ASSIGN_DIM                                               !0, !3
         28        OP_DATA                                                  $16
         29      > JMP                                                      ->32
   23    30    >   ASSIGN_DIM                                               !0, !3
         31        OP_DATA                                                  !2
         32    > > JMP                                                      ->35
   26    33    >   ASSIGN_DIM                                               !0, !3
         34        OP_DATA                                                  !2
   16    35    > > JMP                                                      ->3
         36    >   FE_FREE                                                  $4
   29    37      > RETURN                                                   !0
   30    38*     > RETURN                                                   null

End of function merge

End of class merging.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.41 ms | 1404 KiB | 15 Q