summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-09 12:01:54 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-09 12:01:54 -0700
commitce24eebafcac443fd6572eff80e06b7303f37e36 (patch)
treec425aac0640f20797dae77d5017bece34286e584
parent63b175e2da14c72d77f329f05385402104ef0fc7 (diff)
downloadmc-ce24eebafcac443fd6572eff80e06b7303f37e36.tar.gz
Add hash benchmarks.
-rw-r--r--bench/bld.sub6
-rw-r--r--bench/hashit.myr74
2 files changed, 80 insertions, 0 deletions
diff --git a/bench/bld.sub b/bench/bld.sub
index ae6f225..50ce1d4 100644
--- 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
diff --git a/bench/hashit.myr b/bench/hashit.myr
new file mode 100644
index 0000000..4856bf9
--- /dev/null
+++ b/bench/hashit.myr
@@ -0,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" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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