ref: ce24eebafcac443fd6572eff80e06b7303f37e36
parent: 63b175e2da14c72d77f329f05385402104ef0fc7
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 9 08:01:54 EDT 2017
Add hash benchmarks.
--- a/bench/bld.sub
+++ b/bench/bld.sub
@@ -1,3 +1,9 @@
+bench hashit =
+ hashit.myr
+ lib ../lib/std:std
+ lib ../lib/sys:sys
+ lib ../lib/testr:testr
+;;
bench intsort =
intsort.myr
lib ../lib/std:std
--- /dev/null
+++ b/bench/hashit.myr
@@ -1,0 +1,74 @@
+use std
+use testr
+
+const main = {
+ testr.bench([
+ [.name="hashstr", .fn={ctx;
+ for var i = 0; i < 1000; i++
+ std.strhash("foobar")
+ ;;
+ }],
+ [.name="hashint", .fn={ctx;
+ for var i = 0; i < 1000; i++
+ std.inthash(123)
+ ;;
+ }],
+ [.name="hashlongstr", .fn={ctx;
+ for var i = 0; i < 1000; i++
+ std.strhash(a)
+ ;;
+ }]
+ ][:])
+}
+
+const a = \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaa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