From 4382851e13634e5968ae2b450f7e0dcbad1ebe61 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sat, 4 Aug 2012 10:06:40 -0700 Subject: [PATCH] benchmark.find-pi: adding the bignum ratio find-pi benchmark. --- extra/benchmark/find-pi/find-pi.factor | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 extra/benchmark/find-pi/find-pi.factor diff --git a/extra/benchmark/find-pi/find-pi.factor b/extra/benchmark/find-pi/find-pi.factor new file mode 100644 index 0000000000..585e82ba35 --- /dev/null +++ b/extra/benchmark/find-pi/find-pi.factor @@ -0,0 +1,16 @@ +! Copyright (C) 2012 John Benediktsson +! See http://factorcode.org/license.txt for BSD license. +USING: kernel locals math ; +IN: benchmark.find-pi + +:: find-pi-to ( accuracy -- n approx ) + 1 4 [ + over [ 2 * 1 + ] [ odd? [ neg ] when ] bi + 4 swap / [ + ] keep + abs accuracy >= [ 1 + ] 2dip + ] loop ; + +: find-pi-benchmark ( -- ) + 0.0005 find-pi-to drop 4001 assert= ; + +MAIN: find-pi-benchmark