From 5e9de85aac9b55171c06916049ea7341485946f2 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 24 Sep 2009 22:11:23 -0500 Subject: [PATCH] add benchmarks to cacluate e using decimals, ratios --- work/benchmark/e-decimals/authors.txt | 1 + work/benchmark/e-decimals/e-decimals.factor | 14 ++++++++++++++ work/benchmark/e-ratios/authors.txt | 1 + work/benchmark/e-ratios/e-ratios.factor | 12 ++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 work/benchmark/e-decimals/authors.txt create mode 100644 work/benchmark/e-decimals/e-decimals.factor create mode 100644 work/benchmark/e-ratios/authors.txt create mode 100644 work/benchmark/e-ratios/e-ratios.factor diff --git a/work/benchmark/e-decimals/authors.txt b/work/benchmark/e-decimals/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/work/benchmark/e-decimals/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/work/benchmark/e-decimals/e-decimals.factor b/work/benchmark/e-decimals/e-decimals.factor new file mode 100644 index 0000000000..d202e5ff76 --- /dev/null +++ b/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 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 diff --git a/work/benchmark/e-ratios/authors.txt b/work/benchmark/e-ratios/authors.txt new file mode 100644 index 0000000000..b4bd0e7b35 --- /dev/null +++ b/work/benchmark/e-ratios/authors.txt @@ -0,0 +1 @@ +Doug Coleman \ No newline at end of file diff --git a/work/benchmark/e-ratios/e-ratios.factor b/work/benchmark/e-ratios/e-ratios.factor new file mode 100644 index 0000000000..4957822b5e --- /dev/null +++ b/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 -- 2.34.1