# HG changeset patch # User Mike Pavone # Date 1280728556 14400 # Node ID f4fd8962c385408d17e76672fc87a119352142b1 # Parent 05c22ff4b4eda42a8f447faf70701f222beb8158 Cleaned up binary trees benchmark, made memory allocator somewhat configurable at compile time diff -r 05c22ff4b4ed -r f4fd8962c385 binary_trees.rhope --- 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"] + } } diff -r 05c22ff4b4ed -r f4fd8962c385 runtime/fixed_alloc.h --- 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)))