summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-02 23:27:11 -0700
committerOri Bernstein <ori@eigenstate.org>2015-10-02 23:27:11 -0700
commit08442dd9c3426e2dbe598ef1f6fb10f2f67638aa (patch)
treef8a9d3092248258e5a33bb17fe3a985868ae2ef8 /bench
parent76086513de9efd7a000d0bc229c3e990f0af5a2f (diff)
downloadmc-08442dd9c3426e2dbe598ef1f6fb10f2f67638aa.tar.gz
Implement some asm optimized memcpy/memmove checks.
TODO: memcmp
Diffstat (limited to 'bench')
-rw-r--r--bench/bld.sub9
-rw-r--r--bench/copious-allocs.myr20
-rw-r--r--bench/many-memcpy.myr27
3 files changed, 46 insertions, 10 deletions
diff --git a/bench/bld.sub b/bench/bld.sub
index a6117ba..484226d 100644
--- a/bench/bld.sub
+++ b/bench/bld.sub
@@ -31,6 +31,14 @@ bin regex-match =
lib @/lib/sys:sys
lib @/lib/regex:regex
;;
+
+bin many-memcpy =
+ memcpy.myr
+ lib @/lib/std:std
+ lib @/lib/sys:sys
+;;
+
+# benchmark runner
bin runbench =
runbench.myr
lib @/lib/std:std
@@ -45,4 +53,5 @@ cmd benchit =
bigfactorial
mandelbrot
regex-match
+ many-memcpy
;;
diff --git a/bench/copious-allocs.myr b/bench/copious-allocs.myr
index 1237b7f..7b02594 100644
--- a/bench/copious-allocs.myr
+++ b/bench/copious-allocs.myr
@@ -5,32 +5,31 @@ type blob = struct
;;
const main = {
- var i, j
var a : blob#[10000]
- for j = 0; j < 100; j++
+ for var j = 0; j < 100; j++
/* alloc forwards, dealloc forwards */
- for i = 0; i < a.len; i++
+ for var i = 0; i < a.len; i++
a[i] = std.alloc()
;;
- for i = 0; i < a.len; i++
+ for var i = 0; i < a.len; i++
std.free(a[i])
;;
/* alloc forwards, dealloc backwards */
- for i = 0; i < a.len; i++
+ for var i = 0; i < a.len; i++
a[i] = std.alloc()
;;
- for i = a.len; i > 0; i--
+ for var i = a.len; i > 0; i--
std.free(a[i - 1])
;;
/* alloc forwards, dealloc randomly */
- for i = 0; i < a.len; i++
+ for var i = 0; i < a.len; i++
a[i] = std.alloc()
;;
shuffle(a[:])
- for i = a.len; i > 0; i--
+ for var i = a.len; i > 0; i--
std.free(a[i - 1])
;;
;;
@@ -39,10 +38,11 @@ const main = {
const shuffle = {a
var t
var rng
- var i, j
+ var j
+ /* we want determinism for benchmarking */
rng = std.mksrng(123)
- for i = 0; i < a.len - 1; i++
+ for var i = 0; i < a.len - 1; i++
j = std.rngrand(rng, i, a.len)
t = a[j]
a[j] = a[i]
diff --git a/bench/many-memcpy.myr b/bench/many-memcpy.myr
new file mode 100644
index 0000000..94a5486
--- /dev/null
+++ b/bench/many-memcpy.myr
@@ -0,0 +1,27 @@
+use std
+
+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])
+ ;;
+ ;;
+}
+
+