summaryrefslogtreecommitdiff
path: root/bench/bigfactorial.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-09-12 00:33:02 -0400
committerOri Bernstein <ori@eigenstate.org>2014-09-12 00:33:02 -0400
commitcf92bf1191e3725f31afa7575a05c7970a52c09f (patch)
tree7f84b14864becb5829b56b8092e8581550f3dbac /bench/bigfactorial.myr
parentf831f82b37be253a4f7ab3ffd3719a5dca248754 (diff)
downloadmc-cf92bf1191e3725f31afa7575a05c7970a52c09f.tar.gz
Add a big factorial benchmark.
Diffstat (limited to 'bench/bigfactorial.myr')
-rw-r--r--bench/bigfactorial.myr26
1 files changed, 26 insertions, 0 deletions
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
+}