3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.72 ms | 1400 KiB | 25 Q