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