From 6d9286a2021196370ae61ade3552f0382dbe9cc7 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Tue, 7 Dec 2021 08:36:08 -0600 Subject: Add some more changes to hashing to improve pointer hashing. --- tools/hashbench/ints1.janet | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/hashbench/ints1.janet (limited to 'tools') 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) -- cgit v1.2.3