1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-27 17:00:27 +00:00
janet/tools/hashbench/ints1.janet

25 lines
637 B
Plaintext

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