changeset 95:f4fd8962c385

Cleaned up binary trees benchmark, made memory allocator somewhat configurable at compile time
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Aug 2010 01:55:56 -0400
parents 05c22ff4b4ed
children 5a08705f7610
files binary_trees.rhope runtime/fixed_alloc.h
diffstat 2 files changed, 33 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/binary_trees.rhope	Mon Aug 02 01:00:37 2010 -0400
+++ b/binary_trees.rhope	Mon Aug 02 01:55:56 2010 -0400
@@ -54,11 +54,12 @@
 {
 	sum <- Test Size[0, 1, iterations, current]	
 	{	
-		Print[[iterations]*[2]]
-		{ Print["trees of depth"]
-		{ Print[current]
-		{ Print["check"]
-		{ Print[sum]
+		Print[
+			[[[[String[[iterations]*[2]]
+			]Append["\t trees of depth "]
+			]Append[String[current]]
+			]Append["\t check: "]
+			]Append[String[sum]]]
 		{
 			If[[current]=[max]]
 			{
@@ -66,19 +67,30 @@
 			}{
 				out <- Test Sizes[[current]+[2], max, [iterations]/[4]]
 			}
-		}}}}}
+		}
 	}
 }
 
-Main[]
+Main[args]
 {
-	min depth <- 4
-	max depth <- 16
-	Print["stretch tree of depth 17 check:"]
-	{ Print[Check Tree[Make Tree[0, 17]]] 
-	{ long lived <- Make Tree[0, max depth]
-	{ Test Sizes[min depth, max depth, [1]LShift[max depth]]
-	{ Print["long lived tree of depth 16 check:"]
-	{ Print[Check Tree[long lived]] }}}}}
+	[args]Index[1]
+	{
+		min depth <- 4
+		max depth <- Max[[min depth]+[2], Int32[~]]
+		Print[
+			[[["stretch tree of depth "
+			]Append[String[[max depth]+[1]]]
+			]Append["\t check: "]
+			]Append[String[Check Tree[Make Tree[0, [max depth]+[1]]]]]]
+		{ long lived <- Make Tree[0, max depth]
+		{ Test Sizes[min depth, max depth, [1]LShift[max depth]]
+		{ Print[
+			[[["long lived tree of depth "
+			]Append[String[max depth]]
+			]Append["\t check: "]
+			]Append[String[Check Tree[long lived]]]] }}}
+	}{
+		Print["you must provide a max depth param"]
+	}
 }
 
--- a/runtime/fixed_alloc.h	Mon Aug 02 01:00:37 2010 -0400
+++ b/runtime/fixed_alloc.h	Mon Aug 02 01:55:56 2010 -0400
@@ -8,9 +8,15 @@
 #define GET_BLOCK(ptr) ((void*)(((uintptr_t)(ptr))&(~((uintptr_t)(BLOCK_SIZE-1)))))
 
 #define MAX_SIZE   (BLOCK_SIZE/32)
+#ifndef STRIDE
 #define STRIDE     (BLOCK_SIZE/1024)
+#endif
+#ifndef MIN_SIZE
 #define MIN_SIZE   (BLOCK_SIZE/1024)
+#endif
+#ifndef MAX_FREE
 #define MAX_FREE   64
+#endif
 
 #define ADJUST_SIZE(requested) (((requested)+(STRIDE-1)) & (~(STRIDE-1)))