3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * PHP Array key exists */ $n = 1000; // First a test with a empty array $array = array(); $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = isset($array[$i++]); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - isset(array[i]) on empty array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = array_key_exists($i++, $array); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - array_key_exists(array,i) on empty array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = (bool)@$array[$i++]; //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - cast array[i] on empty array \n"; // Create test array $i = 0; $array = array(); while($i < $n) { $array[$i++] = true; } $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = isset($array[$i++]); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - isset(array[i]) on full array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = array_key_exists($i++, $array); //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - array_key_exists(array,i) on full array \n"; $time_start = microtime(true); $i = 0; while($i < $n){ $devnull = (bool)@$array[$i++]; //var_dump($devnull); } $time_end = microtime(true); $time_while1= $time_end-$time_start; echo number_format($time_while1, 3, '.', '') ." seconds - cast array[i] on full array \n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 33
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 58
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 83
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 97
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 99, Position 2 = 94
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 122
Branch analysis from position: 122
2 jumps found. (Code = 44) Position 1 = 124, Position 2 = 119
Branch analysis from position: 124
1 jumps found. (Code = 42) Position 1 = 150
Branch analysis from position: 150
2 jumps found. (Code = 44) Position 1 = 152, Position 2 = 144
Branch analysis from position: 152
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 144
2 jumps found. (Code = 44) Position 1 = 152, Position 2 = 144
Branch analysis from position: 152
Branch analysis from position: 144
Branch analysis from position: 119
2 jumps found. (Code = 44) Position 1 = 124, Position 2 = 119
Branch analysis from position: 124
Branch analysis from position: 119
Branch analysis from position: 94
2 jumps found. (Code = 44) Position 1 = 99, Position 2 = 94
Branch analysis from position: 99
Branch analysis from position: 94
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 88, Position 2 = 83
Branch analysis from position: 88
Branch analysis from position: 83
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 58
Branch analysis from position: 66
Branch analysis from position: 58
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 33
Branch analysis from position: 38
Branch analysis from position: 33
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
Branch analysis from position: 8
filename:       /in/uT8Om
function name:  (null)
number of ops:  167
compiled vars:  !0 = $n, !1 = $array, !2 = $time_start, !3 = $i, !4 = $devnull, !5 = $time_end, !6 = $time_while1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 1000
    9     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !2, $9
   12     6        ASSIGN                                                   !3, 0
   13     7      > JMP                                                      ->11
   14     8    >   POST_INC                                         ~12     !3
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !1, ~12
         10        ASSIGN                                                   !4, ~13
   13    11    >   IS_SMALLER                                               !3, !0
         12      > JMPNZ                                                    ~15, ->8
   17    13    >   INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !5, $16
   18    17        SUB                                              ~18     !5, !2
         18        ASSIGN                                                   !6, ~18
   19    19        INIT_FCALL                                               'number_format'
         20        SEND_VAR                                                 !6
         21        SEND_VAL                                                 3
         22        SEND_VAL                                                 '.'
         23        SEND_VAL                                                 ''
         24        DO_ICALL                                         $20     
   20    25        CONCAT                                           ~21     $20, '+seconds+-+isset%28array%5Bi%5D%29+on+empty+array+%0A'
         26        ECHO                                                     ~21
   23    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $22     
         30        ASSIGN                                                   !2, $22
   24    31        ASSIGN                                                   !3, 0
   25    32      > JMP                                                      ->36
   26    33    >   POST_INC                                         ~25     !3
         34        ARRAY_KEY_EXISTS                                 ~26     ~25, !1
         35        ASSIGN                                                   !4, ~26
   25    36    >   IS_SMALLER                                               !3, !0
         37      > JMPNZ                                                    ~28, ->33
   29    38    >   INIT_FCALL                                               'microtime'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $29     
         41        ASSIGN                                                   !5, $29
   30    42        SUB                                              ~31     !5, !2
         43        ASSIGN                                                   !6, ~31
   31    44        INIT_FCALL                                               'number_format'
         45        SEND_VAR                                                 !6
         46        SEND_VAL                                                 3
         47        SEND_VAL                                                 '.'
         48        SEND_VAL                                                 ''
         49        DO_ICALL                                         $33     
   32    50        CONCAT                                           ~34     $33, '+seconds+-+array_key_exists%28array%2Ci%29+on+empty+array+%0A'
         51        ECHO                                                     ~34
   34    52        INIT_FCALL                                               'microtime'
         53        SEND_VAL                                                 <true>
         54        DO_ICALL                                         $35     
         55        ASSIGN                                                   !2, $35
   35    56        ASSIGN                                                   !3, 0
   36    57      > JMP                                                      ->64
   37    58    >   BEGIN_SILENCE                                    ~38     
         59        POST_INC                                         ~39     !3
         60        FETCH_DIM_R                                      ~40     !1, ~39
         61        END_SILENCE                                              ~38
         62        BOOL                                             ~41     ~40
         63        ASSIGN                                                   !4, ~41
   36    64    >   IS_SMALLER                                               !3, !0
         65      > JMPNZ                                                    ~43, ->58
   40    66    >   INIT_FCALL                                               'microtime'
         67        SEND_VAL                                                 <true>
         68        DO_ICALL                                         $44     
         69        ASSIGN                                                   !5, $44
   41    70        SUB                                              ~46     !5, !2
         71        ASSIGN                                                   !6, ~46
   42    72        INIT_FCALL                                               'number_format'
         73        SEND_VAR                                                 !6
         74        SEND_VAL                                                 3
         75        SEND_VAL                                                 '.'
         76        SEND_VAL                                                 ''
         77        DO_ICALL                                         $48     
   43    78        CONCAT                                           ~49     $48, '+seconds+-+cast+array%5Bi%5D+on+empty+array+%0A'
         79        ECHO                                                     ~49
   46    80        ASSIGN                                                   !3, 0
   47    81        ASSIGN                                                   !1, <array>
   48    82      > JMP                                                      ->86
   49    83    >   POST_INC                                         ~52     !3
         84        ASSIGN_DIM                                               !1, ~52
         85        OP_DATA                                                  <true>
   48    86    >   IS_SMALLER                                               !3, !0
         87      > JMPNZ                                                    ~54, ->83
   52    88    >   INIT_FCALL                                               'microtime'
         89        SEND_VAL                                                 <true>
         90        DO_ICALL                                         $55     
         91        ASSIGN                                                   !2, $55
   53    92        ASSIGN                                                   !3, 0
   54    93      > JMP                                                      ->97
   55    94    >   POST_INC                                         ~58     !3
         95        ISSET_ISEMPTY_DIM_OBJ                         0  ~59     !1, ~58
         96        ASSIGN                                                   !4, ~59
   54    97    >   IS_SMALLER                                               !3, !0
         98      > JMPNZ                                                    ~61, ->94
   58    99    >   INIT_FCALL                                               'microtime'
        100        SEND_VAL                                                 <true>
        101        DO_ICALL                                         $62     
        102        ASSIGN                                                   !5, $62
   59   103        SUB                                              ~64     !5, !2
        104        ASSIGN                                                   !6, ~64
   60   105        INIT_FCALL                                               'number_format'
        106        SEND_VAR                                                 !6
        107        SEND_VAL                                                 3
        108        SEND_VAL                                                 '.'
        109        SEND_VAL                                                 ''
        110        DO_ICALL                                         $66     
   61   111        CONCAT                                           ~67     $66, '+seconds+-+isset%28array%5Bi%5D%29+on+full+array+%0A'
        112        ECHO                                                     ~67
   64   113        INIT_FCALL                                               'microtime'
        114        SEND_VAL                                                 <true>
        115        DO_ICALL                                         $68     
        116        ASSIGN                                                   !2, $68
   65   117        ASSIGN                                                   !3, 0
   66   118      > JMP                                                      ->122
   67   119    >   POST_INC                                         ~71     !3
        120        ARRAY_KEY_EXISTS                                 ~72     ~71, !1
        121        ASSIGN                                                   !4, ~72
   66   122    >   IS_SMALLER                                               !3, !0
        123      > JMPNZ                                                    ~74, ->119
   70   124    >   INIT_FCALL                                               'microtime'
        125        SEND_VAL                                                 <true>
        126        DO_ICALL                                         $75     
        127        ASSIGN                                                   !5, $75
   71   128        SUB                                              ~77     !5, !2
        129        ASSIGN                                                   !6, ~77
   72   130        INIT_FCALL                                               'number_format'
        131        SEND_VAR                                                 !6
        132        SEND_VAL                                                 3
        133        SEND_VAL                                                 '.'
        134        SEND_VAL                                                 ''
        135        DO_ICALL                                         $79     
   73   136        CONCAT                                           ~80     $79, '+seconds+-+array_key_exists%28array%2Ci%29+on+full+array+%0A'
        137        ECHO                                                     ~80
   75   138        INIT_FCALL                                               'microtime'
        139        SEND_VAL                                                 <true>
        140        DO_ICALL                                         $81     
        141        ASSIGN                                                   !2, $81
   76   142        ASSIGN                                                   !3, 0
   77   143      > JMP                                                      ->150
   78   144    >   BEGIN_SILENCE                                    ~84     
        145        POST_INC                                         ~85     !3
        146        FETCH_DIM_R                                      ~86     !1, ~85
        147        END_SILENCE                                              ~84
        148        BOOL                                             ~87     ~86
        149        ASSIGN                                                   !4, ~87
   77   150    >   IS_SMALLER                                               !3, !0
        151      > JMPNZ                                                    ~89, ->144
   81   152    >   INIT_FCALL                                               'microtime'
        153        SEND_VAL                                                 <true>
        154        DO_ICALL                                         $90     
        155        ASSIGN                                                   !5, $90
   82   156        SUB                                              ~92     !5, !2
        157        ASSIGN                                                   !6, ~92
   83   158        INIT_FCALL                                               'number_format'
        159        SEND_VAR                                                 !6
        160        SEND_VAL                                                 3
        161        SEND_VAL                                                 '.'
        162        SEND_VAL                                                 ''
        163        DO_ICALL                                         $94     
   84   164        CONCAT                                           ~95     $94, '+seconds+-+cast+array%5Bi%5D+on+full+array+%0A'
        165        ECHO                                                     ~95
   87   166      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.89 ms | 1404 KiB | 17 Q