shithub: mc

Download patch

ref: 52af0fabaa1b7b36a1848f53b1abb4538dcebabc
parent: 437f6d851e88446fba90495a3175f02e8d3d390c
author: Ori Bernstein <[email protected]>
date: Fri Aug 15 11:21:33 EDT 2014

Add copious allocs to benchmarks.

--- 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 @@
 bench: runner $(BENCHSRC:.myr=)
 	./runner $(BENCHSRC:.myr=)
 
-$(BENCHSRC:.myr=): $(BENCHSRC) $(BENCHUTIL)
-	../myrbuild/myrbuild -b $@ [email protected] $(BENCHUTIL)
+$(BENCHSRC:.myr=): $(BENCHSRC)
+	../myrbuild/myrbuild -b $@ [email protected]
--- /dev/null
+++ b/bench/copious-allocs.myr
@@ -1,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])
+		;;
+	;;
+}