3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); $results = array(); for($i = 0; $i < 100000; $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 $result->date . "<br />"; } } 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; } echo $result->date . "<br />"; $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 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 22
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 56
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 77) Position 1 = 58, Position 2 = 70
Branch analysis from position: 58
2 jumps found. (Code = 78) Position 1 = 59, Position 2 = 70
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 63
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 56
Branch analysis from position: 74
Branch analysis from position: 56
Branch analysis from position: 70
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 39
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 39
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: 39
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 22
Branch analysis from position: 43
Branch analysis from position: 22
Branch analysis from position: 39
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/VQN3X
function name:  (null)
number of ops:  82
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, 100000
         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                                                      ->41
   11    22    >   ASSIGN                                                   !3, <array>
   12    23      > FE_RESET_R                                       $19     !0, ->39
         24    > > FE_FETCH_R                                               $19, !4, ->39
   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
   17    35        FETCH_OBJ_R                                      ~24     !4, 'date'
         36        CONCAT                                           ~25     ~24, '%3Cbr+%2F%3E'
         37        ECHO                                                     ~25
   12    38      > JMP                                                      ->24
         39    >   FE_FREE                                                  $19
   10    40        PRE_INC                                                  !1
         41    >   IS_SMALLER                                               !1, 1000
         42      > JMPNZ                                                    ~27, ->22
   20    43    >   INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $28     
         46        SUB                                              ~29     $28, !2
         47        CONCAT                                           ~30     'in_array%3A+', ~29
         48        CONCAT                                           ~31     ~30, 'ms+%7C%7C+'
         49        ECHO                                                     ~31
   22    50        INIT_FCALL                                               'microtime'
         51        SEND_VAL                                                 <true>
         52        DO_ICALL                                         $32     
         53        ASSIGN                                                   !5, $32
   23    54        ASSIGN                                                   !1, 0
         55      > JMP                                                      ->72
   24    56    >   ASSIGN                                                   !6, <array>
   25    57      > FE_RESET_R                                       $36     !0, ->70
         58    > > FE_FETCH_R                                               $36, !4, ->70
   26    59    >   FETCH_OBJ_R                                      ~37     !4, 'date'
         60        FETCH_DIM_R                                      ~38     !6, ~37
         61      > JMPZ                                                     ~38, ->63
   27    62    > > JMP                                                      ->58
   29    63    >   FETCH_OBJ_R                                      ~39     !4, 'date'
         64        CONCAT                                           ~40     ~39, '%3Cbr+%2F%3E'
         65        ECHO                                                     ~40
   30    66        FETCH_OBJ_R                                      ~41     !4, 'date'
         67        ASSIGN_DIM                                               !6, ~41
         68        OP_DATA                                                  <true>
   25    69      > JMP                                                      ->58
         70    >   FE_FREE                                                  $36
   23    71        PRE_INC                                                  !1
         72    >   IS_SMALLER                                               !1, 1000
         73      > JMPNZ                                                    ~44, ->56
   33    74    >   INIT_FCALL                                               'microtime'
         75        SEND_VAL                                                 <true>
         76        DO_ICALL                                         $45     
         77        SUB                                              ~46     $45, !5
         78        CONCAT                                           ~47     'by+key%3A+', ~46
         79        CONCAT                                           ~48     ~47, 'ms'
         80        ECHO                                                     ~48
         81      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.77 ms | 1404 KiB | 21 Q