diff options
Diffstat (limited to 'tests/programs/bench_share.zc')
| -rw-r--r-- | tests/programs/bench_share.zc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/programs/bench_share.zc b/tests/programs/bench_share.zc index 6fa478f..04306fe 100644 --- a/tests/programs/bench_share.zc +++ b/tests/programs/bench_share.zc @@ -1,30 +1,33 @@ +namespace; +include rt; + // walk one shared spine from two parents. the checksum is one repetition. fn build() { let i = 0, spine = 0; - while (i < 40) { spine = cons(i, spine); i++; } - return cons(cons(spine, 1), cons(spine, 2)); + while (i < 40) { spine = rt.cons(i, spine); i++; } + return rt.cons(rt.cons(spine, 1), rt.cons(spine, 2)); } fn sum(t) { let a = 0; - while (t) { a = a + car(t); t = cdr(t); } + while (t) { a = a + rt.car(t); t = rt.cdr(t); } return a; } fn work() { - let ch = get_c(), reps = 0, acc = 0, root, spine, k; - while (ch >= '0' && ch <= '9') { reps = reps * 10 + ch - '0'; ch = get_c(); } + let ch = rt.get_c(), reps = 0, acc = 0, root, spine, k; + while (ch >= '0' && ch <= '9') { reps = reps * 10 + ch - '0'; ch = rt.get_c(); } root = build(); - spine = car(car(root)); + spine = rt.car(rt.car(root)); while (reps > 0) { k = 0; acc = 0; while (k < 200) { acc = acc + sum(spine); k++; } - acc = acc + cdr(car(root)) + cdr(cdr(root)); + acc = acc + rt.cdr(rt.car(root)) + rt.cdr(rt.cdr(root)); reps--; } return acc; } fn main() { - put_n(work()); - put_c(10); + rt.put_n(work()); + rt.put_c(10); return 0; } |
