3v4l.org

run code in 300+ PHP versions simultaneously
<?php $loops = 100000; $start = microtime(true); for ($l = 0; $l < $loops; $l++) { $x = [1,2,3,4,6,7,8,9]; for ($i = 0; $i <= 10; $i++) { if (!in_array($i, $x)) { $x[] = $i; } } } $duration = microtime(true) - $start; echo "in_array took $duration<br>".PHP_EOL; $start = microtime(true); for ($l = 0; $l < $loops; $l++) { $x = [1,2,3,4,6,7,8,9]; $x = array_values(array_unique(array_merge($x, [0,1,2,3,4,5,6,7,8,9,10]))); } $duration = microtime(true) - $start; echo "array_unique took $duration<br>".PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 7
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 40
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 40
Branch analysis from position: 55
Branch analysis from position: 40
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 7
Branch analysis from position: 24
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
Branch analysis from position: 10
Branch analysis from position: 18
filename:       /in/lkTCF
function name:  (null)
number of ops:  66
compiled vars:  !0 = $loops, !1 = $start, !2 = $l, !3 = $x, !4 = $i, !5 = $duration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 100000
    4     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    5     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->22
    6     7    >   ASSIGN                                                   !3, <array>
    7     8        ASSIGN                                                   !4, 0
          9      > JMP                                                      ->19
    8    10    >   INIT_FCALL                                               'in_array'
         11        SEND_VAR                                                 !4
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $12     
         14        BOOL_NOT                                         ~13     $12
         15      > JMPZ                                                     ~13, ->18
    9    16    >   ASSIGN_DIM                                               !3
         17        OP_DATA                                                  !4
    7    18    >   PRE_INC                                                  !4
         19    >   IS_SMALLER_OR_EQUAL                                      !4, 10
         20      > JMPNZ                                                    ~16, ->10
    5    21    >   PRE_INC                                                  !2
         22    >   IS_SMALLER                                               !2, !0
         23      > JMPNZ                                                    ~18, ->7
   13    24    >   INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $19     
         27        SUB                                              ~20     $19, !1
         28        ASSIGN                                                   !5, ~20
   14    29        ROPE_INIT                                     3  ~23     'in_array+took+'
         30        ROPE_ADD                                      1  ~23     ~23, !5
         31        ROPE_END                                      2  ~22     ~23, '%3Cbr%3E'
         32        CONCAT                                           ~25     ~22, '%0A'
         33        ECHO                                                     ~25
   16    34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $26     
         37        ASSIGN                                                   !1, $26
   17    38        ASSIGN                                                   !2, 0
         39      > JMP                                                      ->53
   18    40    >   ASSIGN                                                   !3, <array>
   19    41        INIT_FCALL                                               'array_values'
         42        INIT_FCALL                                               'array_unique'
         43        INIT_FCALL                                               'array_merge'
         44        SEND_VAR                                                 !3
         45        SEND_VAL                                                 <array>
         46        DO_ICALL                                         $30     
         47        SEND_VAR                                                 $30
         48        DO_ICALL                                         $31     
         49        SEND_VAR                                                 $31
         50        DO_ICALL                                         $32     
         51        ASSIGN                                                   !3, $32
   17    52        PRE_INC                                                  !2
         53    >   IS_SMALLER                                               !2, !0
         54      > JMPNZ                                                    ~35, ->40
   21    55    >   INIT_FCALL                                               'microtime'
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $36     
         58        SUB                                              ~37     $36, !1
         59        ASSIGN                                                   !5, ~37
   22    60        ROPE_INIT                                     3  ~40     'array_unique+took+'
         61        ROPE_ADD                                      1  ~40     ~40, !5
         62        ROPE_END                                      2  ~39     ~40, '%3Cbr%3E'
         63        CONCAT                                           ~42     ~39, '%0A'
         64        ECHO                                                     ~42
   23    65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.82 ms | 1007 KiB | 18 Q