diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-09-12 00:33:02 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-09-12 00:33:02 -0400 |
commit | 6b0a400370a39fdb924cb9172ef2241f7fc2a096 (patch) | |
tree | 7f84b14864becb5829b56b8092e8581550f3dbac /bench | |
parent | bc3ef744e68cc21d9e899f177e934a937aec8afc (diff) | |
download | mc-6b0a400370a39fdb924cb9172ef2241f7fc2a096.tar.gz |
Add a big factorial benchmark.
Diffstat (limited to 'bench')
-rw-r--r-- | bench/Makefile | 1 | ||||
-rw-r--r-- | bench/bigfactorial.myr | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/bench/Makefile b/bench/Makefile index 4a15fd9..e6f7381 100644 --- a/bench/Makefile +++ b/bench/Makefile @@ -3,6 +3,7 @@ OBJ=runner.o BENCHSRC=intsort.myr \ copious-allocs.myr \ sha1-compute.myr \ + bigfactorial.myr \ include ../config.mk include ../mk/c.mk diff --git a/bench/bigfactorial.myr b/bench/bigfactorial.myr new file mode 100644 index 0000000..fdb8fbc --- /dev/null +++ b/bench/bigfactorial.myr @@ -0,0 +1,26 @@ +use std + +const N = 600 +const main = { + var i + for i = 0; i < N; i++ + std.bigfree(bigfact(i)) + ;; +} + +const bigfact = {n + var i + var x, y + + if n == 0 + x = std.mkbigint(1) + else + x = std.mkbigint(n) + for i = n; i > 0; i-- + y = std.mkbigint(i) + std.bigmul(x, y) + std.bigfree(y) + ;; + ;; + -> x +} |