summaryrefslogtreecommitdiff
path: root/bench/sha1-compute.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-09-04 02:58:44 -0700
committerOri Bernstein <ori@eigenstate.org>2017-09-04 02:58:54 -0700
commit7ef09f3db883c42d01e3b1d80f0d2da6ceff9913 (patch)
treeaf370bd4f281a680b9793034f3b5baee1aa43471 /bench/sha1-compute.myr
parent40d6f7b5cc0cb9e5de1675a1441ad0dfc0a66bda (diff)
downloadmc-7ef09f3db883c42d01e3b1d80f0d2da6ceff9913.tar.gz
Modernize benchmarks.
Diffstat (limited to 'bench/sha1-compute.myr')
-rw-r--r--bench/sha1-compute.myr30
1 files changed, 18 insertions, 12 deletions
diff --git a/bench/sha1-compute.myr b/bench/sha1-compute.myr
index e96aa65..def82a0 100644
--- a/bench/sha1-compute.myr
+++ b/bench/sha1-compute.myr
@@ -1,20 +1,26 @@
use crypto
use std
+use testr
+
+var buf : byte[128*1024*1024]
-const N = 20
const main = {
- var i, b
- var buf : byte[1024*1024]
+ for var i = 0; i < buf.len; i++
+ buf[i] = (i : byte)
+ ;;
+ testr.bench([
+ [.name="sha1-1kb", .fn={ctx; hash(std.KiB)}],
+ [.name="sha1-1mb", .fn={ctx; hash(std.MiB)}],
+ [.name="sha1-16mb", .fn={ctx; hash(16*std.MiB)}],
+ [.name="sha1-128mb", .fn={ctx; hash(128*std.MiB)}],
+ ][:])
+}
+
+const hash = {len
var st
- b = 0
- for i = 0; i < buf.len; i++
- buf[i] = b++
- ;;
- for i = 0; i < N; i++
- crypto.sha1init(&st)
- crypto.sha1add(&st, buf[:])
- crypto.sha1fin(&st)
- ;;
+ crypto.sha1init(&st)
+ crypto.sha1add(&st, buf[:len])
+ crypto.sha1fin(&st)
}