3v4l.org

run code in 300+ PHP versions simultaneously
<?php $max = 1000000; $arr = range(1,$max,3); $arr2 = range(1,$max,2); $arr = array_merge($arr,$arr2); $time = -microtime(true); $res1 = array_unique($arr); $time += microtime(true); echo "deduped to ".count($res1)." in ".$time; // deduped to 666667 in 32.300781965256 $time = -microtime(true); $res2 = array(); foreach($arr as $key=>$val) { $res2[$val] = true; } $res2 = array_keys($res2); $time += microtime(true); echo "<br />deduped to ".count($res2)." in ".$time; // deduped to 666667 in 0.84372591972351
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/h2stK
function name:  (null)
number of ops:  63
compiled vars:  !0 = $max, !1 = $arr, !2 = $arr2, !3 = $time, !4 = $res1, !5 = $res2, !6 = $val, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 1000000
    3     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 1
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 3
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
    4     7        INIT_FCALL                                               'range'
          8        SEND_VAL                                                 1
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 2
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !2, $11
    5    13        INIT_FCALL                                               'array_merge'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !1, $13
    7    18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $15     
         21        MUL                                              ~16     $15, -1
         22        ASSIGN                                                   !3, ~16
    8    23        INIT_FCALL                                               'array_unique'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !4, $18
    9    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $20     
         30        ASSIGN_OP                                     1          !3, $20
   10    31        COUNT                                            ~22     !4
         32        CONCAT                                           ~23     'deduped+to+', ~22
         33        CONCAT                                           ~24     ~23, '+in+'
         34        CONCAT                                           ~25     ~24, !3
         35        ECHO                                                     ~25
   13    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $26     
         39        MUL                                              ~27     $26, -1
         40        ASSIGN                                                   !3, ~27
   14    41        ASSIGN                                                   !5, <array>
   15    42      > FE_RESET_R                                       $30     !1, ->48
         43    > > FE_FETCH_R                                       ~31     $30, !6, ->48
         44    >   ASSIGN                                                   !7, ~31
   16    45        ASSIGN_DIM                                               !5, !6
         46        OP_DATA                                                  <true>
   15    47      > JMP                                                      ->43
         48    >   FE_FREE                                                  $30
   18    49        INIT_FCALL                                               'array_keys'
         50        SEND_VAR                                                 !5
         51        DO_ICALL                                         $34     
         52        ASSIGN                                                   !5, $34
   19    53        INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $36     
         56        ASSIGN_OP                                     1          !3, $36
   20    57        COUNT                                            ~38     !5
         58        CONCAT                                           ~39     '%3Cbr+%2F%3Ededuped+to+', ~38
         59        CONCAT                                           ~40     ~39, '+in+'
         60        CONCAT                                           ~41     ~40, !3
         61        ECHO                                                     ~41
   21    62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.12 ms | 1400 KiB | 23 Q