summaryrefslogtreecommitdiff
path: root/bench/hashit.myr
diff options
context:
space:
mode:
Diffstat (limited to 'bench/hashit.myr')
-rw-r--r--bench/hashit.myr74
1 files changed, 74 insertions, 0 deletions
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" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
+ "aaa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