Skip to content

Commit

Permalink
add benchmarks to cacluate e using decimals, ratios
Browse files Browse the repository at this point in the history
  • Loading branch information
erg committed Sep 25, 2009
1 parent 42ef421 commit 88105fd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions work/benchmark/e-decimals/authors.txt
@@ -0,0 +1 @@
Doug Coleman
14 changes: 14 additions & 0 deletions work/benchmark/e-decimals/e-decimals.factor
@@ -0,0 +1,14 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: decimals kernel locals math math.combinatorics math.ranges
sequences ;
IN: benchmark.e-decimals

:: calculate-e-decimals ( n -- e )
n [1,b] [ factorial 0 <decimal> D: 1 swap n D/ ] map
D: 1 [ D+ ] reduce ;

: calculate-e-decimals-benchmark ( -- )
5 [ 800 calculate-e-decimals drop ] times ;

MAIN: calculate-e-decimals-benchmark
1 change: 1 addition & 0 deletions work/benchmark/e-ratios/authors.txt
@@ -0,0 +1 @@
Doug Coleman
12 changes: 12 additions & 0 deletions work/benchmark/e-ratios/e-ratios.factor
@@ -0,0 +1,12 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.combinatorics math.ranges sequences ;
IN: benchmark.e-ratios

: calculate-e-ratios ( n -- e )
iota [ factorial recip ] sigma ;

: calculate-e-ratios-benchmark ( -- )
5 [ 300 calculate-e-ratios drop ] times ;

MAIN: calculate-e-ratios-benchmark

0 comments on commit 88105fd

Please sign in to comment.