3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "<pre>"; $results = array( "m1" => 0, "m2" => 0 ); $repeat = 1000; for($i = 0; $i < $repeat; $i ++) { foreach($results as $k => $no) { $results[$k] += $k($repeat); } if ($i == 0) { printf("First Run\n%s\n\n", json_encode($results, 128)); } } printf("100 Runs\n%s\n", json_encode($results, 128)); function m1($x) { $data = array(); $collision = 0; for($i = 0; $i < $x; $i ++) { $n = (rand() ^ (rand() / getrandmax())) % 256; isset($data[$n]) and $collision ++; $data[$n] = true; } return $collision; } function m2($x) { $data = array(); $collision = 0; for($i = 0; $i < $x; $i ++) { $n = (rand() ^ rand()) % 256; isset($data[$n]) and $collision ++; $data[$n] = true; } return $collision; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 5
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 5
Branch analysis from position: 28
Branch analysis from position: 5
Branch analysis from position: 25
Branch analysis from position: 14
filename:       /in/7LUmK
function name:  (null)
number of ops:  37
compiled vars:  !0 = $results, !1 = $repeat, !2 = $i, !3 = $no, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ECHO                                                     '%3Cpre%3E'
    3     1        ASSIGN                                                   !0, <array>
    7     2        ASSIGN                                                   !1, 1000
    8     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->26
    9     5    > > FE_RESET_R                                       $8      !0, ->14
          6    > > FE_FETCH_R                                       ~9      $8, !3, ->14
          7    >   ASSIGN                                                   !4, ~9
   10     8        INIT_DYNAMIC_CALL                                        !4
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $12     
         11        ASSIGN_DIM_OP                +=               1          !0, !4
         12        OP_DATA                                                  $12
    9    13      > JMP                                                      ->6
         14    >   FE_FREE                                                  $8
   12    15        IS_EQUAL                                                 !2, 0
         16      > JMPZ                                                     ~13, ->25
   13    17    >   INIT_FCALL                                               'printf'
         18        SEND_VAL                                                 'First+Run%0A%25s%0A%0A'
         19        INIT_FCALL                                               'json_encode'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 128
         22        DO_ICALL                                         $14     
         23        SEND_VAR                                                 $14
         24        DO_ICALL                                                 
    8    25    >   PRE_INC                                                  !2
         26    >   IS_SMALLER                                               !2, !1
         27      > JMPNZ                                                    ~17, ->5
   17    28    >   INIT_FCALL                                               'printf'
         29        SEND_VAL                                                 '100+Runs%0A%25s%0A'
         30        INIT_FCALL                                               'json_encode'
         31        SEND_VAR                                                 !0
         32        SEND_VAL                                                 128
         33        DO_ICALL                                         $18     
         34        SEND_VAR                                                 $18
         35        DO_ICALL                                                 
   41    36      > RETURN                                                   1

Function m1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 5
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 5
Branch analysis from position: 24
Branch analysis from position: 5
Branch analysis from position: 19
filename:       /in/7LUmK
function name:  m1
number of ops:  26
compiled vars:  !0 = $x, !1 = $data, !2 = $collision, !3 = $i, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN                                                   !1, <array>
   21     2        ASSIGN                                                   !2, 0
   22     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->22
   23     5    >   INIT_FCALL                                               'rand'
          6        DO_ICALL                                         $8      
          7        INIT_FCALL                                               'rand'
          8        DO_ICALL                                         $9      
          9        INIT_FCALL                                               'getrandmax'
         10        DO_ICALL                                         $10     
         11        DIV                                              ~11     $9, $10
         12        BW_XOR                                           ~12     $8, ~11
         13        MOD                                              ~13     ~12, 256
         14        ASSIGN                                                   !4, ~13
   24    15        ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !1, !4
         16      > JMPZ_EX                                          ~15     ~15, ->19
         17    >   POST_INC                                         ~16     !2
         18        BOOL                                             ~15     ~16
   25    19    >   ASSIGN_DIM                                               !1, !4
         20        OP_DATA                                                  <true>
   22    21        PRE_INC                                                  !3
         22    >   IS_SMALLER                                               !3, !0
         23      > JMPNZ                                                    ~19, ->5
   27    24    > > RETURN                                                   !2
   28    25*     > RETURN                                                   null

End of function m1

Function m2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
Branch analysis from position: 16
filename:       /in/7LUmK
function name:  m2
number of ops:  23
compiled vars:  !0 = $x, !1 = $data, !2 = $collision, !3 = $i, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        ASSIGN                                                   !1, <array>
   32     2        ASSIGN                                                   !2, 0
   33     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->19
   34     5    >   INIT_FCALL                                               'rand'
          6        DO_ICALL                                         $8      
          7        INIT_FCALL                                               'rand'
          8        DO_ICALL                                         $9      
          9        BW_XOR                                           ~10     $8, $9
         10        MOD                                              ~11     ~10, 256
         11        ASSIGN                                                   !4, ~11
   35    12        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !1, !4
         13      > JMPZ_EX                                          ~13     ~13, ->16
         14    >   POST_INC                                         ~14     !2
         15        BOOL                                             ~13     ~14
   36    16    >   ASSIGN_DIM                                               !1, !4
         17        OP_DATA                                                  <true>
   33    18        PRE_INC                                                  !3
         19    >   IS_SMALLER                                               !3, !0
         20      > JMPNZ                                                    ~17, ->5
   38    21    > > RETURN                                                   !2
   39    22*     > RETURN                                                   null

End of function m2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.9 ms | 1404 KiB | 21 Q