3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.94 ms | 1019 KiB | 18 Q