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 55f49a7e56fb094e45fa7bfe978cdda7c11f8634
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sat, 16 Oct 2010 13:59:32 +0200

Initial commit

Diffstat:
AMakefile | 19+++++++++++++++++++
AREADME | 7+++++++
Afibo25.l | 6++++++
Afibo25.lua | 9+++++++++
Afibo30.l | 6++++++
Afibo30.lua | 9+++++++++
Afibo40.c | 11+++++++++++
Afibo40.l | 6++++++
Afibo40.lua | 9+++++++++
9 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,19 @@ +all: fibo40 + +fibo40: fibo40.c + gcc -O2 -o fibo40 fibo40.c + +bench: + cat fibo25.l | time ~/lisp/picoLisp-3.0.4/bin/picolisp + cat fibo30.l | time ~/lisp/picoLisp-3.0.4/bin/picolisp + cat fibo40.l | time ~/lisp/picoLisp-3.0.4/bin/picolisp + cat fibo25.lua | time lua + cat fibo30.lua | time lua + cat fibo40.lua | time lua + cat fibo25.lua | time luajit-2.0.0-beta2 + cat fibo30.lua | time luajit-2.0.0-beta2 + cat fibo40.lua | time luajit-2.0.0-beta2 + time ./fibo40 + +clean: + rm -f *~ *.o fibo40 diff --git a/README b/README @@ -0,0 +1,7 @@ +-*- org -*- + +| | pil64-3.0.4 | lua-5.1 | luajit-2.0.0 | c -O2 | +|---------+-------------+---------+--------------+-------| +| fibo 25 | 0.03 | 0.02 | 0.02 | | +| fibo 30 | 0.27 | 0.19 | 0.08 | | +| fibo 40 | 31.08 | 22.70 | 8.82 | 1.31 | diff --git a/fibo25.l b/fibo25.l @@ -0,0 +1,6 @@ +(de fibo (N) + (if (> 2 N) + 1 + (+ (fibo (dec N)) (fibo (- N 2))) ) ) +(fibo 25) +(bye) diff --git a/fibo25.lua b/fibo25.lua @@ -0,0 +1,9 @@ +fib = function(n) + if n < 3 then + return n + else + return fib(n - 1) + fib(n - 2) + end +end + +print(fib(25)) diff --git a/fibo30.l b/fibo30.l @@ -0,0 +1,6 @@ +(de fibo (N) + (if (> 2 N) + 1 + (+ (fibo (dec N)) (fibo (- N 2))) ) ) +(fibo 30) +(bye) diff --git a/fibo30.lua b/fibo30.lua @@ -0,0 +1,9 @@ +fib = function(n) + if n < 3 then + return n + else + return fib(n - 1) + fib(n - 2) + end +end + +print(fib(30)) diff --git a/fibo40.c b/fibo40.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +static int fibo(int n) { + if(n < 3) return n; + else return fibo(n - 1) + fibo(n - 2); +} + +int main() { + printf("%d\n", fibo(40)); + return 0; +} diff --git a/fibo40.l b/fibo40.l @@ -0,0 +1,6 @@ +(de fibo (N) + (if (> 2 N) + 1 + (+ (fibo (dec N)) (fibo (- N 2))) ) ) +(fibo 40) +(bye) diff --git a/fibo40.lua b/fibo40.lua @@ -0,0 +1,9 @@ +fib = function(n) + if n < 3 then + return n + else + return fib(n - 1) + fib(n - 2) + end +end + +print(fib(40))