benchmark.find-pi: adding the bignum ratio find-pi benchmark.

db4
John Benediktsson 2012-08-04 10:06:40 -07:00
parent 61a6b5692f
commit 4382851e13
1 changed files with 16 additions and 0 deletions

View File

@ -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