diff options
| author | 2021-12-07 08:36:08 -0600 | |
|---|---|---|
| committer | 2021-12-07 08:36:08 -0600 | |
| commit | 6d9286a2021196370ae61ade3552f0382dbe9cc7 (patch) | |
| tree | 78d592fb0a3d1b42cb2ca773c1c0458bdb5ff08d /tools | |
| parent | Address #889 - Switch high and low bits of part of number hash (Knuth's multi... (diff) | |
Add some more changes to hashing to improve pointer hashing.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/hashbench/ints1.janet | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/hashbench/ints1.janet b/tools/hashbench/ints1.janet new file mode 100644 index 00000000..37219e13 --- /dev/null +++ b/tools/hashbench/ints1.janet @@ -0,0 +1,24 @@ +(def f @{}) +(var collisions 0) +(loop [x :range [0 300] y :range [0 300]] + (def key (hash (+ (* x 1000) y))) + (if (in f key) + (++ collisions)) + (put f key true)) +(print "ints 1 collisions: " collisions) + +(def f @{}) +(var collisions 0) +(loop [x :range [100000 101000] y :range [100000 101000]] + (def key (hash [x y])) + (if (in f key) (++ collisions)) + (put f key true)) +(print "int pair 1 collisions: " collisions) + +(def f @{}) +(var collisions 0) +(loop [x :range [10000 11000] y :range [10000 11000]] + (def key (hash [x y])) + (if (in f key) (++ collisions)) + (put f key true)) +(print "int pair 2 collisions: " collisions) |
