summaryrefslogtreecommitdiff
path: root/bench/many-memcpy.myr
diff options
context:
space:
mode:
Diffstat (limited to 'bench/many-memcpy.myr')
-rw-r--r--bench/many-memcpy.myr46
1 files changed, 25 insertions, 21 deletions
diff --git a/bench/many-memcpy.myr b/bench/many-memcpy.myr
index 94a5486..7fce209 100644
--- a/bench/many-memcpy.myr
+++ b/bench/many-memcpy.myr
@@ -1,27 +1,31 @@
use std
+use testr
+
+var a : uint64[100000]
const main = {
- var a : uint64[100000]
-
- for var j = 0; j < 100; j++
- /* independent copies forward */
- for var i = 0; i < 10; i++
- std.slcp(a[:a.len/2-1], a[a.len/2+1:])
- ;;
- /* independent copies backward */
- for var i = 0; i < 10; i++
- std.slcp(a[:a.len/2-1], a[a.len/2+1:])
- ;;
-
- /* dependent copies forward */
- for var i = 0; i < 10; i++
- std.slcp(a[:a.len/2+1000], a[a.len/2-1000:])
- ;;
- /* dependent copies backward */
- for var i = 0; i < 10; i++
- std.slcp(a[a.len/2-1000:], a[:a.len/2+1000])
- ;;
- ;;
+ testr.bench([
+ [.name="fwd-independent", .fn=fwd_independent],
+ [.name="rev-independent", .fn=rev_independent],
+ [.name="fwd-dependent", .fn=fwd_dependent],
+ [.name="rev-dependent", .fn=rev_dependent],
+ ][:])
+}
+
+const fwd_independent = {ctx
+ std.slcp(a[:a.len/2-1], a[a.len/2+1:])
+}
+
+const rev_independent = {ctx
+ std.slcp(a[:a.len/2-1], a[a.len/2+1:])
+}
+
+const fwd_dependent = {ctx
+ std.slcp(a[:a.len/2+1000], a[a.len/2-1000:])
+}
+
+const rev_dependent = {ctx
+ std.slcp(a[a.len/2-1000:], a[:a.len/2+1000])
}