shithub: mc

Download patch

ref: 6b0a400370a39fdb924cb9172ef2241f7fc2a096
parent: bc3ef744e68cc21d9e899f177e934a937aec8afc
author: Ori Bernstein <[email protected]>
date: Thu Sep 11 20:33:02 EDT 2014

Add a big factorial benchmark.

--- a/bench/Makefile
+++ b/bench/Makefile
@@ -3,6 +3,7 @@
 BENCHSRC=intsort.myr \
 	 copious-allocs.myr \
 	 sha1-compute.myr \
+	 bigfactorial.myr \
 
 include ../config.mk
 include ../mk/c.mk
--- /dev/null
+++ b/bench/bigfactorial.myr
@@ -1,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
+}