1
0
mirror of https://github.com/janet-lang/janet synced 2025-09-06 12:58:04 +00:00

Add some more changes to hashing to improve pointer hashing.

This commit is contained in:
Calvin Rose
2021-12-07 08:36:08 -06:00
parent 92fdd07ca3
commit 6d9286a202
2 changed files with 31 additions and 5 deletions

View File

@@ -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)