3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); $amount = 100000; $start = microtime(true); $alreadyOutput = array(); $iterator = $amount; while ($iterator --) { $num = rand(0, $amount); if(in_array($num, $alreadyOutput)){ continue; } $alreadyOutput[] = $num; } echo "in_array: ".(microtime(true) - $start)."ms || "; unset($alreadyOutput); $alreadyOutput = array(); $start2 = microtime(true); $iterator = $amount; while ($iterator --) { $num = rand(0, $amount); if(isset($alreadyOutput[$num])){ continue; } $alreadyOutput[$num] = true; } echo "by key: ".(microtime(true) - $start2)."ms";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 11
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 41
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 41
Branch analysis from position: 53
Branch analysis from position: 41
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 11
Branch analysis from position: 26
Branch analysis from position: 11
filename:       /in/uFUbH
function name:  (null)
number of ops:  61
compiled vars:  !0 = $amount, !1 = $start, !2 = $alreadyOutput, !3 = $iterator, !4 = $num, !5 = $start2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    3     3        ASSIGN                                                   !0, 100000
    4     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
    5     8        ASSIGN                                                   !2, <array>
    7     9        ASSIGN                                                   !3, !0
    8    10      > JMP                                                      ->24
    9    11    >   INIT_FCALL                                               'rand'
         12        SEND_VAL                                                 0
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !4, $12
   10    16        INIT_FCALL                                               'in_array'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $14     
         20      > JMPZ                                                     $14, ->22
   11    21    > > JMP                                                      ->24
   13    22    >   ASSIGN_DIM                                               !2
         23        OP_DATA                                                  !4
    8    24    >   POST_DEC                                         ~16     !3
         25      > JMPNZ                                                    ~16, ->11
   16    26    >   INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $17     
         29        SUB                                              ~18     $17, !1
         30        CONCAT                                           ~19     'in_array%3A+', ~18
         31        CONCAT                                           ~20     ~19, 'ms+%7C%7C+'
         32        ECHO                                                     ~20
   18    33        UNSET_CV                                                 !2
   19    34        ASSIGN                                                   !2, <array>
   21    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $22     
         38        ASSIGN                                                   !5, $22
   22    39        ASSIGN                                                   !3, !0
   23    40      > JMP                                                      ->51
   24    41    >   INIT_FCALL                                               'rand'
         42        SEND_VAL                                                 0
         43        SEND_VAR                                                 !0
         44        DO_ICALL                                         $25     
         45        ASSIGN                                                   !4, $25
   25    46        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
         47      > JMPZ                                                     ~27, ->49
   26    48    > > JMP                                                      ->51
   28    49    >   ASSIGN_DIM                                               !2, !4
         50        OP_DATA                                                  <true>
   23    51    >   POST_DEC                                         ~29     !3
         52      > JMPNZ                                                    ~29, ->41
   30    53    >   INIT_FCALL                                               'microtime'
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $30     
         56        SUB                                              ~31     $30, !5
         57        CONCAT                                           ~32     'by+key%3A+', ~31
         58        CONCAT                                           ~33     ~32, 'ms'
         59        ECHO                                                     ~33
         60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.81 ms | 1400 KiB | 21 Q