Common Lisp Benchmark on Ubuntu

The common lisp source code here is a fibnacci program.

Common Lisp Code:

(defun fib (n)
    (if (or (= n 1) (= n 2))
        1
        (+ (fib (- n 1)) (fib (- n 2)))))

(let ((n (read)))
    (format t "~D~%" (fib n)))

C Code:

#include <stdio.h>

int fib(int n)
{
    if (1 == n || 2 == n) return 1;
    return fib(n-1)+fib(n-2);
}


int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", fib(n));
    return 0;
}

C++ Code:

#include <iostream>
using namespace std;


int fib(int n)
{
    if (1 == n || 2 == n) return 1;
    return fib(n-1)+fib(n-2);
}


int main()
{
    int n;
    cin >> n;
    cout << fib(n) << endl;
    return 0;
}

benchmark.sh

time clisp main.lisp < in.txt > /dev/null
time sbcl --script main.lisp < in.txt > /dev/null
time ./mainc < in.txt > /dev/null
time ./maincpp < in.txt > /dev/null

benchmark result:

ismdeep@Linux:~/lisp-benchmark$ bash benchmark.sh 

real    1m28.319s
user    1m28.317s
sys    0m0.004s

real    0m1.643s
user    0m1.630s
sys    0m0.012s

real    0m0.438s
user    0m0.437s
sys    0m0.000s

real    0m0.444s
user    0m0.444s
sys    0m0.000s