bench-fibo

Unnamed repository; edit this file 'description' to name the repository.
git clone https://logand.com/git/bench-fibo.git/
Log | Files | Refs | README

commit d3582536d69cc0c1a5346f0e690066dd46ee39db
parent c92cb0420871e44d59f214a862e5afcd2378ce69
Author: Tomas Hlavaty <tom@logand.com>
Date:   Fri, 22 Oct 2010 01:51:37 +0200

added fibo40int2.java fibo40int3.java and results updated

Diffstat:
MMakefile | 12++++++++++--
MREADME | 12++++++------
Afibo40int2.java | 11+++++++++++
Afibo40int3.java | 15+++++++++++++++
4 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -all: fibo40 ofibo40 fibo40int.class fibo40.class +all: fibo40 ofibo40 fibo40int.class fibo40int2.class fibo40int3.class fibo40.class .c.l: @@ -11,6 +11,12 @@ ofibo40: ofibo40.m fibo40int.class: fibo40int.java javac fibo40int.java +fibo40int2.class: fibo40int2.java + javac fibo40int2.java + +fibo40int3.class: fibo40int3.java + javac fibo40int3.java + fibo40.class: fibo40.java javac fibo40.java @@ -27,7 +33,9 @@ bench: time ./fibo40 time ./ofibo40 time java fibo40int + time java fibo40int2 + time java fibo40int3 time java fibo40 clean: - rm -f *~ *.o fibo40 ofibo40 fibo40int.class fibo40.class + rm -f *~ *.o *.class fibo40 ofibo40 diff --git a/README b/README @@ -1,8 +1,8 @@ -*- org -*- -| | pil64 | lua | luajit | java big | gcc -O2 | gobjc | java int | -| | 3.0.4 | 5.1 | 2.0.0 | IcedTea6 1.8.1 | 4.4.3 | | | -|---------+-------+-------+--------+----------------+---------+-------+----------| -| fibo 25 | 0.02 | 0.02 | 0.01 | | | | | -| fibo 30 | 0.16 | 0.18 | 0.08 | | | | | -| fibo 40 | 19.54 | 22.32 | 8.78 | 22.12 | 1.30 | 3.35 | 0.85 | +| | pil64 | lua | luajit | java big | gcc -O2 | gobjc | java int | java int2 | java int3 | +| | 3.0.4 | 5.1 | 2.0.0 | IcedTea6 1.8.1 | 4.4.3 | | | | | +|---------+-------+-------+--------+----------------+---------+-------+----------+-----------+-----------| +| fibo 25 | 0.02 | 0.02 | 0.01 | | | | | | | +| fibo 30 | 0.16 | 0.18 | 0.08 | | | | | | | +| fibo 40 | 19.54 | 22.32 | 8.78 | 22.12 | 1.30 | 3.35 | 0.85 | 0.78 | 0.83 | diff --git a/fibo40int2.java b/fibo40int2.java @@ -0,0 +1,11 @@ +class fibo40int2 { + + int fibo(int n) { + if(n < 3) return n; + else return fibo(n - 1) + fibo(n - 2); + } + + public static void main(String args[]) { + System.out.println(new fibo40int2().fibo(40)); + } +} diff --git a/fibo40int3.java b/fibo40int3.java @@ -0,0 +1,15 @@ +class fibo40int3 { + + interface Fibo { + int fibo(int n); + } + + public static void main(String args[]) { + System.out.println(new Fibo() { + public int fibo(int n) { + if(n < 3) return n; + else return fibo(n - 1) + fibo(n - 2); + } + }.fibo(40)); + } +}