3v4l.org

run code in 500+ 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 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 37
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 37
Branch analysis from position: 52
Branch analysis from position: 37
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 7
Branch analysis from position: 21
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
Branch analysis from position: 10
Branch analysis from position: 15
filename:       /in/lkTCF
function name:  (null)
number of ops:  63
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                                                          ->19
    6     7    >   ASSIGN                                                       !3, <array>
    7     8        ASSIGN                                                       !4, 0
          9      > JMP                                                          ->16
    8    10    >   FRAMELESS_ICALL_2                in_array            ~12     !4, !3
         11        BOOL_NOT                                             ~13     ~12
         12      > JMPZ                                                         ~13, ->15
    9    13    >   ASSIGN_DIM                                                   !3
         14        OP_DATA                                                      !4
    7    15    >   PRE_INC                                                      !4
         16    >   IS_SMALLER_OR_EQUAL                                          !4, 10
         17      > JMPNZ                                                        ~16, ->10
    5    18    >   PRE_INC                                                      !2
         19    >   IS_SMALLER                                                   !2, !0
         20      > JMPNZ                                                        ~18, ->7
   13    21    >   INIT_FCALL                                                   'microtime'
         22        SEND_VAL                                                     <true>
         23        DO_ICALL                                             $19     
         24        SUB                                                  ~20     $19, !1
         25        ASSIGN                                                       !5, ~20
   14    26        ROPE_INIT                                         3  ~23     'in_array+took+'
         27        ROPE_ADD                                          1  ~23     ~23, !5
         28        ROPE_END                                          2  ~22     ~23, '%3Cbr%3E'
         29        CONCAT                                               ~25     ~22, '%0A'
         30        ECHO                                                         ~25
   16    31        INIT_FCALL                                                   'microtime'
         32        SEND_VAL                                                     <true>
         33        DO_ICALL                                             $26     
         34        ASSIGN                                                       !1, $26
   17    35        ASSIGN                                                       !2, 0
         36      > JMP                                                          ->50
   18    37    >   ASSIGN                                                       !3, <array>
   19    38        INIT_FCALL                                                   'array_values'
         39        INIT_FCALL                                                   'array_unique'
         40        INIT_FCALL                                                   'array_merge'
         41        SEND_VAR                                                     !3
         42        SEND_VAL                                                     <array>
         43        DO_ICALL                                             $30     
         44        SEND_VAR                                                     $30
         45        DO_ICALL                                             $31     
         46        SEND_VAR                                                     $31
         47        DO_ICALL                                             $32     
         48        ASSIGN                                                       !3, $32
   17    49        PRE_INC                                                      !2
         50    >   IS_SMALLER                                                   !2, !0
         51      > JMPNZ                                                        ~35, ->37
   21    52    >   INIT_FCALL                                                   'microtime'
         53        SEND_VAL                                                     <true>
         54        DO_ICALL                                             $36     
         55        SUB                                                  ~37     $36, !1
         56        ASSIGN                                                       !5, ~37
   22    57        ROPE_INIT                                         3  ~40     'array_unique+took+'
         58        ROPE_ADD                                          1  ~40     ~40, !5
         59        ROPE_END                                          2  ~39     ~40, '%3Cbr%3E'
         60        CONCAT                                               ~42     ~39, '%0A'
         61        ECHO                                                         ~42
   23    62      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.77 ms | 1530 KiB | 17 Q