From 82b73565bf24a984658974790c8ada32632f5a6a Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 26 Aug 2019 12:41:01 -0700 Subject: [PATCH] performance test for murmur32 vs murmur64 --- testcases/tests/t0695.nim | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 testcases/tests/t0695.nim diff --git a/testcases/tests/t0695.nim b/testcases/tests/t0695.nim new file mode 100644 index 0000000..8348c60 --- /dev/null +++ b/testcases/tests/t0695.nim @@ -0,0 +1,89 @@ +#[ +D20190624T193837 murmur +]# + +import std/[hashes,oids,tables,strutils, times] +import std/math +import ../../murmur/murmur +import pkg/sysrandom + +when defined(case_with_murmur): + # proc hash*(x: string): Hash {.inline.} = toHashMurmur3(x, nBits=128)[0].Hash + proc hash*(x: string): Hash {.inline.} = toHashMurmur3(x, nBits=64).Hash + +when defined(case_with_hash_silly): + proc hash*(x: string): Hash {.inline.} = + result = toHashMurmur3("asdf")[0].Hash + # echo result + +when defined(case_with_bytewiseHashing): + proc hash*(x: string): Hash {.inline.} = bytewiseHashing(result, x, 0, high(x)) + +# template run(keyFun: untyped, s: string) = +proc run[Fun](keyFun: Fun, s: string) = + var t: Table[string, string] + let n = 100_000 + var keys: seq[string] + var keys0: seq[string] + + var tKey, tHash, tInsert, tGet: float + var dummy = 0 # prevent optimizing out + + block: + let t0 = epochTime() + for i in 0..