3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); $amount = 1000000; $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 || "; $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 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 39
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 39
Branch analysis from position: 51
Branch analysis from position: 39
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/k9T3X
function name:  (null)
number of ops:  59
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, 1000000
    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        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $21     
         36        ASSIGN                                                   !5, $21
   19    37        ASSIGN                                                   !3, !0
   20    38      > JMP                                                      ->49
   21    39    >   INIT_FCALL                                               'rand'
         40        SEND_VAL                                                 0
         41        SEND_VAR                                                 !0
         42        DO_ICALL                                         $24     
         43        ASSIGN                                                   !4, $24
   22    44        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
         45      > JMPZ                                                     ~26, ->47
   23    46    > > JMP                                                      ->49
   25    47    >   ASSIGN_DIM                                               !2, !4
         48        OP_DATA                                                  <true>
   20    49    >   POST_DEC                                         ~28     !3
         50      > JMPNZ                                                    ~28, ->39
   27    51    >   INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $29     
         54        SUB                                              ~30     $29, !5
         55        CONCAT                                           ~31     'by+key%3A+', ~30
         56        CONCAT                                           ~32     ~31, 'ms'
         57        ECHO                                                     ~32
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.56 ms | 1400 KiB | 21 Q