diff options
Diffstat (limited to 'tests/programs/allocfast.zc')
| -rw-r--r-- | tests/programs/allocfast.zc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/programs/allocfast.zc b/tests/programs/allocfast.zc index 5ef2df2..d7b1d93 100644 --- a/tests/programs/allocfast.zc +++ b/tests/programs/allocfast.zc @@ -1,3 +1,6 @@ +namespace; +include rt; + // repeated allocations of a size known at compile time: new(T) of a struct of // numbers, and new(n) with a constant n. each pass of the loop makes an object // and frees it at the end of the block, so the allocator should hand back the @@ -8,7 +11,7 @@ struct line { point* a; int len; }; fn loop_leaf(int n) { let total = 0; for (int i = 0; i < n; i++) { - point* p = new(point); + point* p = rt.new(point); total += p.x + p.y; // zero from the allocator, every pass p.x = i; p.y = 2; } @@ -17,7 +20,7 @@ fn loop_leaf(int n) { fn loop_words(int n) { let total = 0, i = 0; while (i < n) { - let w = new(6); + let w = rt.new(6); total += w[0] + w[5]; w[0] = 7; w[5] = 9; i++; @@ -27,8 +30,8 @@ fn loop_words(int n) { fn loop_owner(int n) { let i = 0, total = 0; while (i < n) { - line* l = new(line); - l.a = new(point); + line* l = rt.new(line); + l.a = rt.new(point); l.a.x = i; total += l.a.x + l.len; i++; @@ -36,10 +39,10 @@ fn loop_owner(int n) { return total; } fn main() { - let before = live_objects(); - put_n(loop_leaf(50000)); put_c(' '); - put_n(loop_words(50000)); put_c(' '); - put_n(loop_owner(1000)); put_c(' '); - put_n(live_objects() - before); put_c(10); + let before = rt.live_objects(); + rt.put_n(loop_leaf(50000)); rt.put_c(' '); + rt.put_n(loop_words(50000)); rt.put_c(' '); + rt.put_n(loop_owner(1000)); rt.put_c(' '); + rt.put_n(rt.live_objects() - before); rt.put_c(10); return 0; } |
