3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('memory_limit', '512m'); $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 $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 // 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 = 47, Position 2 = 52
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 52
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/Ee4oI
function name:  (null)
number of ops:  88
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
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'memory_limit'
          2        SEND_VAL                                                 '512m'
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !0, 100000
    6     5        INIT_FCALL                                               'range'
          6        SEND_VAL                                                 1
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 3
          9        DO_ICALL                                         $11     
         10        ASSIGN                                                   !1, $11
    7    11        INIT_FCALL                                               'range'
         12        SEND_VAL                                                 1
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 2
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !2, $13
    8    17        INIT_FCALL                                               'array_merge'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $15     
         21        ASSIGN                                                   !1, $15
   13    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $17     
         25        MUL                                              ~18     $17, -1
         26        ASSIGN                                                   !3, ~18
   14    27        INIT_FCALL                                               'array_unique'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $20     
         30        ASSIGN                                                   !4, $20
   15    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $22     
         34        ASSIGN_OP                                     1          !3, $22
   16    35        COUNT                                            ~24     !4
         36        CONCAT                                           ~25     'deduped+to+', ~24
         37        CONCAT                                           ~26     ~25, '+in+'
         38        CONCAT                                           ~27     ~26, !3
         39        ECHO                                                     ~27
   20    40        INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $28     
         43        MUL                                              ~29     $28, -1
         44        ASSIGN                                                   !3, ~29
   21    45        ASSIGN                                                   !5, <array>
   22    46      > FE_RESET_R                                       $32     !1, ->52
         47    > > FE_FETCH_R                                       ~33     $32, !6, ->52
         48    >   ASSIGN                                                   !7, ~33
   23    49        ASSIGN_DIM                                               !5, !6
         50        OP_DATA                                                  <true>
   22    51      > JMP                                                      ->47
         52    >   FE_FREE                                                  $32
   25    53        INIT_FCALL                                               'array_keys'
         54        SEND_VAR                                                 !5
         55        DO_ICALL                                         $36     
         56        ASSIGN                                                   !5, $36
   26    57        INIT_FCALL                                               'microtime'
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $38     
         60        ASSIGN_OP                                     1          !3, $38
   27    61        COUNT                                            ~40     !5
         62        CONCAT                                           ~41     '%3Cbr+%2F%3Ededuped+to+', ~40
         63        CONCAT                                           ~42     ~41, '+in+'
         64        CONCAT                                           ~43     ~42, !3
         65        ECHO                                                     ~43
   33    66        INIT_FCALL                                               'microtime'
         67        SEND_VAL                                                 <true>
         68        DO_ICALL                                         $44     
         69        MUL                                              ~45     $44, -1
         70        ASSIGN                                                   !3, ~45
   34    71        INIT_FCALL                                               'array_flip'
         72        INIT_FCALL                                               'array_flip'
         73        SEND_VAR                                                 !1
         74        DO_ICALL                                         $47     
         75        SEND_VAR                                                 $47
         76        DO_ICALL                                         $48     
         77        ASSIGN                                                   !8, $48
   36    78        INIT_FCALL                                               'microtime'
         79        SEND_VAL                                                 <true>
         80        DO_ICALL                                         $50     
         81        ASSIGN_OP                                     1          !3, $50
   37    82        COUNT                                            ~52     !8
         83        CONCAT                                           ~53     '%3Cbr+%2F%3Ededuped+to+', ~52
         84        CONCAT                                           ~54     ~53, '+in+'
         85        CONCAT                                           ~55     ~54, !3
         86        ECHO                                                     ~55
         87      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.77 ms | 1400 KiB | 27 Q