3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; $arrK = array_combine($arr, array_fill(0, count($arr), true)); $iters = 1_000_000; $t = microtime(true); for ($i = 0; $i < $iters; $i++) { $v = ($i % 2) ? 'a' : 'c'; $res = in_array($v, $arr); $res = in_array($v, $arr); $res = in_array($v, $arr); $res = in_array($v, $arr); } var_dump(microtime(true) - $t); $t = microtime(true); for ($i = 0; $i < $iters; $i++) { $v = ($i % 2) ? 'a' : 'c'; $res = array_key_exists($v, $arrK); $res = array_key_exists($v, $arrK); $res = array_key_exists($v, $arrK); $res = array_key_exists($v, $arrK); } var_dump(microtime(true) - $t); $t = microtime(true); for ($i = 0; $i < $iters; $i++) { $v = ($i % 2) ? 'a' : 'c'; $res = array_key_exists($v, array_keys($arr)); $res = array_key_exists($v, array_keys($arr)); $res = array_key_exists($v, array_keys($arr)); $res = array_key_exists($v, array_keys($arr)); } var_dump(microtime(true) - $t); print_r(opcache_get_status());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 19
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 61
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
2 jumps found. (Code = 44) Position 1 = 120, Position 2 = 91
Branch analysis from position: 120
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 91
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 95
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
2 jumps found. (Code = 44) Position 1 = 120, Position 2 = 91
Branch analysis from position: 120
Branch analysis from position: 91
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 120, Position 2 = 91
Branch analysis from position: 120
Branch analysis from position: 91
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 61
Branch analysis from position: 78
Branch analysis from position: 61
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 78, Position 2 = 61
Branch analysis from position: 78
Branch analysis from position: 61
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 19
Branch analysis from position: 48
Branch analysis from position: 19
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 19
Branch analysis from position: 48
Branch analysis from position: 19
filename:       /in/Btrh0
function name:  (null)
number of ops:  133
compiled vars:  !0 = $arr, !1 = $arrK, !2 = $iters, !3 = $t, !4 = $i, !5 = $v, !6 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'array_combine'
          2        SEND_VAR                                                 !0
          3        INIT_FCALL                                               'array_fill'
          4        SEND_VAL                                                 0
          5        COUNT                                            ~8      !0
          6        SEND_VAL                                                 ~8
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $9      
          9        SEND_VAR                                                 $9
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !1, $10
    6    12        ASSIGN                                                   !2, 1000000
    8    13        INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !3, $13
    9    17        ASSIGN                                                   !4, 0
         18      > JMP                                                      ->46
   10    19    >   MOD                                              ~16     !4, 2
         20      > JMPZ                                                     ~16, ->23
         21    >   QM_ASSIGN                                        ~17     'a'
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~17     'c'
         24    >   ASSIGN                                                   !5, ~17
   11    25        INIT_FCALL                                               'in_array'
         26        SEND_VAR                                                 !5
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $19     
         29        ASSIGN                                                   !6, $19
   12    30        INIT_FCALL                                               'in_array'
         31        SEND_VAR                                                 !5
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $21     
         34        ASSIGN                                                   !6, $21
   13    35        INIT_FCALL                                               'in_array'
         36        SEND_VAR                                                 !5
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                         $23     
         39        ASSIGN                                                   !6, $23
   14    40        INIT_FCALL                                               'in_array'
         41        SEND_VAR                                                 !5
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                         $25     
         44        ASSIGN                                                   !6, $25
    9    45        PRE_INC                                                  !4
         46    >   IS_SMALLER                                               !4, !2
         47      > JMPNZ                                                    ~28, ->19
   16    48    >   INIT_FCALL                                               'var_dump'
         49        INIT_FCALL                                               'microtime'
         50        SEND_VAL                                                 <true>
         51        DO_ICALL                                         $29     
         52        SUB                                              ~30     $29, !3
         53        SEND_VAL                                                 ~30
         54        DO_ICALL                                                 
   18    55        INIT_FCALL                                               'microtime'
         56        SEND_VAL                                                 <true>
         57        DO_ICALL                                         $32     
         58        ASSIGN                                                   !3, $32
   19    59        ASSIGN                                                   !4, 0
         60      > JMP                                                      ->76
   20    61    >   MOD                                              ~35     !4, 2
         62      > JMPZ                                                     ~35, ->65
         63    >   QM_ASSIGN                                        ~36     'a'
         64      > JMP                                                      ->66
         65    >   QM_ASSIGN                                        ~36     'c'
         66    >   ASSIGN                                                   !5, ~36
   21    67        ARRAY_KEY_EXISTS                                 ~38     !5, !1
         68        ASSIGN                                                   !6, ~38
   22    69        ARRAY_KEY_EXISTS                                 ~40     !5, !1
         70        ASSIGN                                                   !6, ~40
   23    71        ARRAY_KEY_EXISTS                                 ~42     !5, !1
         72        ASSIGN                                                   !6, ~42
   24    73        ARRAY_KEY_EXISTS                                 ~44     !5, !1
         74        ASSIGN                                                   !6, ~44
   19    75        PRE_INC                                                  !4
         76    >   IS_SMALLER                                               !4, !2
         77      > JMPNZ                                                    ~47, ->61
   26    78    >   INIT_FCALL                                               'var_dump'
         79        INIT_FCALL                                               'microtime'
         80        SEND_VAL                                                 <true>
         81        DO_ICALL                                         $48     
         82        SUB                                              ~49     $48, !3
         83        SEND_VAL                                                 ~49
         84        DO_ICALL                                                 
   28    85        INIT_FCALL                                               'microtime'
         86        SEND_VAL                                                 <true>
         87        DO_ICALL                                         $51     
         88        ASSIGN                                                   !3, $51
   29    89        ASSIGN                                                   !4, 0
         90      > JMP                                                      ->118
   30    91    >   MOD                                              ~54     !4, 2
         92      > JMPZ                                                     ~54, ->95
         93    >   QM_ASSIGN                                        ~55     'a'
         94      > JMP                                                      ->96
         95    >   QM_ASSIGN                                        ~55     'c'
         96    >   ASSIGN                                                   !5, ~55
   31    97        INIT_FCALL                                               'array_keys'
         98        SEND_VAR                                                 !0
         99        DO_ICALL                                         $57     
        100        ARRAY_KEY_EXISTS                                 ~58     !5, $57
        101        ASSIGN                                                   !6, ~58
   32   102        INIT_FCALL                                               'array_keys'
        103        SEND_VAR                                                 !0
        104        DO_ICALL                                         $60     
        105        ARRAY_KEY_EXISTS                                 ~61     !5, $60
        106        ASSIGN                                                   !6, ~61
   33   107        INIT_FCALL                                               'array_keys'
        108        SEND_VAR                                                 !0
        109        DO_ICALL                                         $63     
        110        ARRAY_KEY_EXISTS                                 ~64     !5, $63
        111        ASSIGN                                                   !6, ~64
   34   112        INIT_FCALL                                               'array_keys'
        113        SEND_VAR                                                 !0
        114        DO_ICALL                                         $66     
        115        ARRAY_KEY_EXISTS                                 ~67     !5, $66
        116        ASSIGN                                                   !6, ~67
   29   117        PRE_INC                                                  !4
        118    >   IS_SMALLER                                               !4, !2
        119      > JMPNZ                                                    ~70, ->91
   36   120    >   INIT_FCALL                                               'var_dump'
        121        INIT_FCALL                                               'microtime'
        122        SEND_VAL                                                 <true>
        123        DO_ICALL                                         $71     
        124        SUB                                              ~72     $71, !3
        125        SEND_VAL                                                 ~72
        126        DO_ICALL                                                 
   38   127        INIT_FCALL                                               'print_r'
        128        INIT_FCALL_BY_NAME                                       'opcache_get_status'
        129        DO_FCALL                                      0  $74     
        130        SEND_VAR                                                 $74
        131        DO_ICALL                                                 
        132      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.63 ms | 1087 KiB | 20 Q