3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); $results = array(); for($i = 0; $i < 3000; $i++) { $results[] = (object) rand(0, 100000); } $start = microtime(true); for($i = 0; $i < 1000; $i++) { $alreadyOutput = array(); foreach ($results as $result) { if(in_array($result->date, $alreadyOutput)){ continue; } $alreadyOutput[] = $result->date; } } echo "in_array: ".(microtime(true) - $start)."ms || "; $start2 = microtime(true); for($i = 0; $i < 1000; $i++) { $echoedArray = array(); foreach ($results as $result) { if ($echoedArray[$result->date]) { continue; } $echoedArray[$result->date] = true; } } echo "by key: ".(microtime(true) - $start2)."ms";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 6
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 22
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 53
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 77) Position 1 = 55, Position 2 = 64
Branch analysis from position: 55
2 jumps found. (Code = 78) Position 1 = 56, Position 2 = 64
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 60
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 53
Branch analysis from position: 68
Branch analysis from position: 53
Branch analysis from position: 64
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 22
Branch analysis from position: 40
Branch analysis from position: 22
Branch analysis from position: 36
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 6
Branch analysis from position: 16
Branch analysis from position: 6
filename:       /in/hIKP2
function name:  (null)
number of ops:  76
compiled vars:  !0 = $results, !1 = $i, !2 = $start, !3 = $alreadyOutput, !4 = $result, !5 = $start2, !6 = $echoedArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    4     3        ASSIGN                                                   !0, <array>
    5     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->14
    6     6    >   INIT_FCALL                                               'rand'
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 100000
          9        DO_ICALL                                         $11     
         10        CAST                                          8  ~12     $11
         11        ASSIGN_DIM                                               !0
         12        OP_DATA                                                  ~12
    5    13        PRE_INC                                                  !1
         14    >   IS_SMALLER                                               !1, 3000
         15      > JMPNZ                                                    ~14, ->6
    9    16    >   INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $15     
         19        ASSIGN                                                   !2, $15
   10    20        ASSIGN                                                   !1, 0
         21      > JMP                                                      ->38
   11    22    >   ASSIGN                                                   !3, <array>
   12    23      > FE_RESET_R                                       $19     !0, ->36
         24    > > FE_FETCH_R                                               $19, !4, ->36
   13    25    >   INIT_FCALL                                               'in_array'
         26        FETCH_OBJ_R                                      ~20     !4, 'date'
         27        SEND_VAL                                                 ~20
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $21     
         30      > JMPZ                                                     $21, ->32
   14    31    > > JMP                                                      ->24
   16    32    >   FETCH_OBJ_R                                      ~23     !4, 'date'
         33        ASSIGN_DIM                                               !3
         34        OP_DATA                                                  ~23
   12    35      > JMP                                                      ->24
         36    >   FE_FREE                                                  $19
   10    37        PRE_INC                                                  !1
         38    >   IS_SMALLER                                               !1, 1000
         39      > JMPNZ                                                    ~25, ->22
   19    40    >   INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $26     
         43        SUB                                              ~27     $26, !2
         44        CONCAT                                           ~28     'in_array%3A+', ~27
         45        CONCAT                                           ~29     ~28, 'ms+%7C%7C+'
         46        ECHO                                                     ~29
   21    47        INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $30     
         50        ASSIGN                                                   !5, $30
   22    51        ASSIGN                                                   !1, 0
         52      > JMP                                                      ->66
   23    53    >   ASSIGN                                                   !6, <array>
   24    54      > FE_RESET_R                                       $34     !0, ->64
         55    > > FE_FETCH_R                                               $34, !4, ->64
   25    56    >   FETCH_OBJ_R                                      ~35     !4, 'date'
         57        FETCH_DIM_R                                      ~36     !6, ~35
         58      > JMPZ                                                     ~36, ->60
   26    59    > > JMP                                                      ->55
   28    60    >   FETCH_OBJ_R                                      ~37     !4, 'date'
         61        ASSIGN_DIM                                               !6, ~37
         62        OP_DATA                                                  <true>
   24    63      > JMP                                                      ->55
         64    >   FE_FREE                                                  $34
   22    65        PRE_INC                                                  !1
         66    >   IS_SMALLER                                               !1, 1000
         67      > JMPNZ                                                    ~40, ->53
   31    68    >   INIT_FCALL                                               'microtime'
         69        SEND_VAL                                                 <true>
         70        DO_ICALL                                         $41     
         71        SUB                                              ~42     $41, !5
         72        CONCAT                                           ~43     'by+key%3A+', ~42
         73        CONCAT                                           ~44     ~43, 'ms'
         74        ECHO                                                     ~44
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.43 ms | 1404 KiB | 21 Q