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 = []; $arr2 = []; foreach ($rand as $k => $v) { $arr2[$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++) { $arr2 = []; foreach ($rand as $k => $v) { $arr2[$k] = $v; } $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 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 22
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 52
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 59
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 67, Position 2 = 52
Branch analysis from position: 67
Branch analysis from position: 52
Branch analysis from position: 59
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 22
Branch analysis from position: 36
Branch analysis from position: 22
Branch analysis from position: 32
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/bJ43f
function name:  (null)
number of ops:  77
compiled vars:  !0 = $rand, !1 = $max, !2 = $i, !3 = $start, !4 = $keys, !5 = $arr2, !6 = $v, !7 = $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                                         $11     
          8        SEND_VAR                                                 $11
          9        DO_ICALL                                         $12     
         10        ASSIGN_DIM                                               !0, $12
         11        OP_DATA                                                  !2
    6    12        PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !1
         14      > JMPNZ                                                    ~15, ->4
   11    15    >   ASSIGN                                                   !1, 1000
   12    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $17     
         19        ASSIGN                                                   !3, $17
   13    20        ASSIGN                                                   !2, 0
         21      > JMP                                                      ->34
   14    22    >   ASSIGN                                                   !4, <array>
   15    23        ASSIGN                                                   !5, <array>
   16    24      > FE_RESET_R                                       $22     !0, ->32
         25    > > FE_FETCH_R                                       ~23     $22, !6, ->32
         26    >   ASSIGN                                                   !7, ~23
   17    27        ASSIGN_DIM                                               !5, !7
         28        OP_DATA                                                  !6
   18    29        ASSIGN_DIM                                               !4
         30        OP_DATA                                                  !7
   16    31      > JMP                                                      ->25
         32    >   FE_FREE                                                  $22
   13    33        PRE_INC                                                  !2
         34    >   IS_SMALLER                                               !2, !1
         35      > JMPNZ                                                    ~28, ->22
   21    36    >   INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         38        INIT_FCALL                                               'microtime'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $29     
         41        SUB                                              ~30     $29, !3
         42        DIV                                              ~31     ~30, !1
         43        SEND_VAL                                                 ~31
         44        DO_ICALL                                                 
   23    45        ASSIGN                                                   !1, 1000
   24    46        INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $34     
         49        ASSIGN                                                   !3, $34
   25    50        ASSIGN                                                   !2, 0
         51      > JMP                                                      ->65
   26    52    >   ASSIGN                                                   !5, <array>
   27    53      > FE_RESET_R                                       $38     !0, ->59
         54    > > FE_FETCH_R                                       ~39     $38, !6, ->59
         55    >   ASSIGN                                                   !7, ~39
   28    56        ASSIGN_DIM                                               !5, !7
         57        OP_DATA                                                  !6
   27    58      > JMP                                                      ->54
         59    >   FE_FREE                                                  $38
   30    60        INIT_FCALL                                               'array_keys'
         61        SEND_VAR                                                 !0
         62        DO_ICALL                                         $42     
         63        ASSIGN                                                   !4, $42
   25    64        PRE_INC                                                  !2
         65    >   IS_SMALLER                                               !2, !1
         66      > JMPNZ                                                    ~45, ->52
   32    67    >   INIT_FCALL                                               'printf'
         68        SEND_VAL                                                 'Took+%25.7f+seconds+per+execution%0A'
         69        INIT_FCALL                                               'microtime'
         70        SEND_VAL                                                 <true>
         71        DO_ICALL                                         $46     
         72        SUB                                              ~47     $46, !3
         73        DIV                                              ~48     ~47, !1
         74        SEND_VAL                                                 ~48
         75        DO_ICALL                                                 
         76      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.66 ms | 1018 KiB | 18 Q