3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rand = []; $max = 10000; for ($i = 0; $i < $max; $i++) { $rand[bin2hex(random_bytes(10))] = $i; } $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $keys = []; foreach ($rand as $k => $v) { $keys[] = $k; } } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); $max = 1000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $keys = array_keys($rand); } printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 22
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 49
Branch analysis from position: 56
Branch analysis from position: 49
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 22
Branch analysis from position: 33
Branch analysis from position: 22
Branch analysis from position: 29
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 4
Branch analysis from position: 15
Branch analysis from position: 4
filename:       /in/o6pTK
function name:  (null)
number of ops:  66
compiled vars:  !0 = $rand, !1 = $max, !2 = $i, !3 = $start, !4 = $keys, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 10000
    6     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->13
    7     4    >   INIT_FCALL                                               'bin2hex'
          5        INIT_FCALL                                               'random_bytes'
          6        SEND_VAL                                                 10
          7        DO_ICALL                                         $10     
          8        SEND_VAR                                                 $10
          9        DO_ICALL                                         $11     
         10        ASSIGN_DIM                                               !0, $11
         11        OP_DATA                                                  !2
    6    12        PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !1
         14      > JMPNZ                                                    ~14, ->4
   10    15    >   ASSIGN                                                   !1, 1000
   11    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $16     
         19        ASSIGN                                                   !3, $16
   12    20        ASSIGN                                                   !2, 0
         21      > JMP                                                      ->31
   13    22    >   ASSIGN                                                   !4, <array>
   14    23      > FE_RESET_R                                       $20     !0, ->29
         24    > > FE_FETCH_R                                       ~21     $20, !5, ->29
         25    >   ASSIGN                                                   !6, ~21
   15    26        ASSIGN_DIM                                               !4
         27        OP_DATA                                                  !6
   14    28      > JMP                                                      ->24
         29    >   FE_FREE                                                  $20
   12    30        PRE_INC                                                  !2
         31    >   IS_SMALLER                                               !2, !1
         32      > JMPNZ                                                    ~25, ->22
   18    33    >   INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $26     
         38        SUB                                              ~27     $26, !3
         39        DIV                                              ~28     ~27, !1
         40        SEND_VAL                                                 ~28
         41        DO_ICALL                                                 
   20    42        ASSIGN                                                   !1, 1000
   21    43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $31     
         46        ASSIGN                                                   !3, $31
   22    47        ASSIGN                                                   !2, 0
         48      > JMP                                                      ->54
   23    49    >   INIT_FCALL                                               'array_keys'
         50        SEND_VAR                                                 !0
         51        DO_ICALL                                         $34     
         52        ASSIGN                                                   !4, $34
   22    53        PRE_INC                                                  !2
         54    >   IS_SMALLER                                               !2, !1
         55      > JMPNZ                                                    ~37, ->49
   25    56    >   INIT_FCALL                                               'printf'
         57        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         58        INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $38     
         61        SUB                                              ~39     $38, !3
         62        DIV                                              ~40     ~39, !1
         63        SEND_VAL                                                 ~40
         64        DO_ICALL                                                 
         65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.94 ms | 1011 KiB | 18 Q