summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-08-15 15:21:33 -0400
committerOri Bernstein <ori@eigenstate.org>2014-08-15 15:21:33 -0400
commit52af0fabaa1b7b36a1848f53b1abb4538dcebabc (patch)
tree05e0fe9334a637bcd9e6c2d61f0014545ffe629a /bench
parent437f6d851e88446fba90495a3175f02e8d3d390c (diff)
downloadmc-52af0fabaa1b7b36a1848f53b1abb4538dcebabc.tar.gz
Add copious allocs to benchmarks.
Diffstat (limited to 'bench')
-rw-r--r--bench/Makefile8
-rw-r--r--bench/copious-allocs.myr28
2 files changed, 32 insertions, 4 deletions
diff --git a/bench/Makefile b/bench/Makefile
index c94452b..25ce7ad 100644
--- a/bench/Makefile
+++ b/bench/Makefile
@@ -1,7 +1,7 @@
BIN=runner
OBJ=runner.o
-BENCHSRC=intsort.myr
-BENCHUTIL=
+BENCHSRC=intsort.myr \
+ copious-allocs.myr \
include ../config.mk
include ../mk/c.mk
@@ -9,5 +9,5 @@ include ../mk/c.mk
bench: runner $(BENCHSRC:.myr=)
./runner $(BENCHSRC:.myr=)
-$(BENCHSRC:.myr=): $(BENCHSRC) $(BENCHUTIL)
- ../myrbuild/myrbuild -b $@ $@.myr $(BENCHUTIL)
+$(BENCHSRC:.myr=): $(BENCHSRC)
+ ../myrbuild/myrbuild -b $@ $@.myr
diff --git a/bench/copious-allocs.myr b/bench/copious-allocs.myr
new file mode 100644
index 0000000..091b83b
--- /dev/null
+++ b/bench/copious-allocs.myr
@@ -0,0 +1,28 @@
+use std
+
+type blob = struct
+ x : int[10]
+;;
+
+const main = {
+ var i, j
+ var a : blob#[10000]
+
+ for j = 0; j < 100; j++
+ /* alloc forwards, dealloc forwards */
+ for i = 0; i < a.len; i++
+ a[i] = std.alloc()
+ ;;
+ for i = 0; i < a.len; i++
+ std.free(a[i])
+ ;;
+
+ /* alloc forwards, dealloc backwards */
+ for i = 0; i < a.len; i++
+ a[i] = std.alloc()
+ ;;
+ for i = a.len; i > 0; i--
+ std.free(a[i - 1])
+ ;;
+ ;;
+}