fibonacci(40) benchmark
Node.js is Cancer show a wrong way to use nodejs. But the test co
Languages
Dynamic
- nodejs
- nodejs + cpp module
- python
- pypy: a fast, compliant alternative implementation of the Python language.
- jython
- perl
- php
- ruby
- lua
- luajit: a Just-In-Time Compiler for Lua.
Static
If you want to help add more dynamic languagues, please leave the implement co
Results
(^_^) c > java > go > scala > luajit > nodejs > ruby 2.0.0-p0 > pypy > ruby 1.9.3+ > lua > php > python > perl > ruby 1.8.x (T_T)
Language | Times (user) | Position | Version |
---|---|---|---|
c with -O2 | 0m0.202s | #0 | i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) |
nodejs + cpp module | 0m1.001s | #1 | v0.8.8, gcc -O2 |
java | 0m1.305s | #2 | Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811) Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode) |
go | 0m1.667s | #3 | go version go1.0.2 |
scala | 0m1.808s | #4 | Scala co |
luajit | 0m2.579s | #5 | LuaJIT 2.0.0-beta10 -- Copyright (C) 2005-2012 Mike Pall. |
nodejs | 0m2.872s | #6 | v0.8.8 |
ruby 2.0.0-p0 | 0m27.777s | #7 | ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0] |
pypy | 0m30.010s | #8 | Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:42:54) [PyPy 1.9.0 with GCC 4.2.1] |
ruby 1.9.x | 0m37.404s | #9 | ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0] |
lua | 0m40.709s | #10 | Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio |
jython | 0m53.699s | #11 | Jython 2.5.2 |
php | 1m17.728s | #12 | PHP 5.4.6 (cli) (built: Sep 8 2012 23:49:53) |
python | 1m17.979s | #13 | Python 2.7.2 |
perl | 2m41.259s | #14 | This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level |
ruby 1.8.x | 3m35.135s | #15 | ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0] |
lua use local function will get better performance.
fibonacci(40) benchmark result:
c
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >#include <stdio.h>
int fibonacci(n) {
if (n < 2) {
return n;
}
return fibonacci(n - 2) + fibonacci(n - 1);
}
int main() {
printf("%d\n", fibonacci(40));
return 0;
}de>
gcc -O0
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m4.145s
user 0m3.892s
sys 0m0.012sde>
gcc -O1
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m2.732s
user 0m2.610s
sys 0m0.009sde>
gcc -O2
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m0.249s
user 0m0.202s
sys 0m0.004sde>
gcc -O3
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m0.293s
user 0m0.202s
sys 0m0.004sde>
java
java version "1.6.0_35" Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811) Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >public class Fibonacci {
public static int fib(int n) {
if (n < 2) {
return n;
} else {
return fib(n - 1) + fib(n - 2);
}
}
public static void main(String[] args) {
System.out.print(fib(40) + "\n");
}
}de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.413s
user 0m1.305s
sys 0m0.063sde>
scala
Scala co
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >object Fibonacci {
def fib(n: Int): Int = n match {
case 0 | 1 => n
case _ => fib(n -1) + fib(n-2)
}
def main(args: Array[String]) {
println(fib(40));
}
}de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.909s
user 0m1.808s
sys 0m0.121sde>
go
go version go1.0.2
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >package main
import "fmt"
func fibonacci(n int) int{
if (n < 2) {
return n
}
return fibonacci(n - 2) + fibonacci(n - 1)
}
func main() {
fmt.Println(fibonacci(40))
}de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.732s
user 0m1.667s
sys 0m0.006sde>
nodejs
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >function fibonacci(n) {
if (n < 2) {
return n;
}
return fibonacci(n - 2) + fibonacci(n - 1);
}
console.log(fibonacci(40));de>
v0.2.6
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m4.959s
user 0m4.699s
sys 0m0.028sde>
v0.3.8
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m4.961s
user 0m4.867s
sys 0m0.022sde>
v0.4.12
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m7.544s
user 0m7.219s
sys 0m0.030sde>
v0.6.19
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m5.264s
user 0m5.062s
sys 0m0.040sde>
v0.6.20
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m5.413s
user 0m5.195s
sys 0m0.038sde>
v0.6.21-pre
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m5.081s
user 0m4.906s
sys 0m0.037sde>
v0.7.12
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m2.964s
user 0m2.867s
sys 0m0.029sde>
v0.8.0
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.034s
user 0m2.868s
sys 0m0.029sde>
v0.8.1
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.064s
user 0m2.863s
sys 0m0.032sde>
v0.8.3
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.024s
user 0m2.855s
sys 0m0.030sde>
v0.8.6
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.046s
user 0m2.854s
sys 0m0.030sde>
v0.8.7
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.258s
user 0m2.933s
sys 0m0.033sde>
v0.8.8
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.052s
user 0m2.866s
sys 0m0.031sde>
v0.9.1
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m3.190s
user 0m2.852s
sys 0m0.032sde>
nodejs + cpp module
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >var fibonacci = require('./build/Release/cppfibonacci').fibonacci;
console.log(fibonacci(40));de>
waf 1.5.16 (7610:7647M) v0.4.12
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.374s
user 0m1.012s
sys 0m0.024sde>
waf 1.5.16 (7610:7647M) v0.6.20
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.063s
user 0m1.000s
sys 0m0.018sde>
waf 1.5.16 (7610:7647M) v0.8.8
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m1.076s
user 0m1.001s
sys 0m0.015sde>
luajit
LuaJIT 2.0.0-beta10 -- Copyright (C) 2005-2012 Mike Pall. http://luajit.org/
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >function fibonacci(n)
if n < 2 then
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
io.write(fibonacci(40), "\n")de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m2.847s
user 0m2.579s
sys 0m0.013sde>
using 'local'
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >local function fibonacci(n)
if n < 2 then
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
io.write(fibonacci(40), "\n")de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m2.536s
user 0m2.490s
sys 0m0.006sde>
pypy
Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:42:54) [PyPy 1.9.0 with GCC 4.2.1]
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >def fibonacci(n):
if n < 2:
return n
return fibonacci(n - 2) + fibonacci(n - 1)
print fibonacci(40)de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m34.082s
user 0m30.010s
sys 0m0.303sde>
ruby 1.9.x
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >def fibonacci(n)
if n < 2
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
puts fibonacci(40)de>
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.1.0]
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m39.972s
user 0m37.404s
sys 0m0.124sde>
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m29.078s
user 0m27.777s
sys 0m0.072sde>
lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >function fibonacci(n)
if n < 2 then
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
io.write(fibonacci(40), "\n")de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m42.961s
user 0m40.709s
sys 0m0.098sde>
using 'local'
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >local function fibonacci(n)
if n < 2 then
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
io.write(fibonacci(40), "\n")de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m37.178s
user 0m35.887s
sys 0m0.081sde>
python && jython
Python 2.7.2
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >def fibonacci(n):
if n < 2:
return n
return fibonacci(n - 2) + fibonacci(n - 1)
print fibonacci(40)de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 1m23.989s
user 1m17.979s
sys 0m0.303sde>
Jython 2.5.2
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 0m58.651s
user 0m53.699s
sys 0m1.945sde>
php
PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20)
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" ><?php
function fibonacci($n) {
if ($n < 2) {
return $n;
}
return fibonacci($n - 2) + fibonacci($n - 1);
}
echo fibonacci(40)."\n";
?>de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 1m43.579s
user 1m36.905s
sys 0m0.349sde>
PHP 5.4.6 (cli) (built: Sep 8 2012 23:49:53)
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 1m25.155s
user 1m17.728s
sys 0m0.261sde>
perl
This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >sub fibonacci {
my $n = shift;
if ($n < 2) {
return $n;
}
return fibonacci($n - 2) + fibonacci($n - 1);
}
print fibonacci(40), "\n";de>
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 2m53.937s
user 2m41.259s
sys 0m0.592sde>
ruby 1.8.x
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >def fibonacci(n)
if n < 2
return n
end
return fibonacci(n - 2) + fibonacci(n - 1)
end
puts fibonacci(40)de>
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
de style="line-height: 22.75px; box-sizing: border-box; margin: 0px; padding: 0px; font-family: Monaco, Menlo, Consolas, 'Courier New', monospace; word-wrap: break-word; font-size: inherit; color: inherit; border-radius: 4px; border: 0px; background-color: transparent;" >102334155
real 3m59.076s
user 3m35.135s
sys 0m0.833sde>
Conclusion
- go is awsome!
- nodejs is FAST, v0.8+ is FASTER.
- luajit 2X faster than nodejs@0.6.x, Shocking.
- ruby 1.9.x faster than lua.