summaryrefslogtreecommitdiff
path: root/bench/sha1-compute.myr
diff options
context:
space:
mode:
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)
}