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

End of function merge

End of class merging.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.43 ms | 1404 KiB | 15 Q