Skip to content
Yusuke Inuzuka edited this page Feb 27, 2015 · 9 revisions

fib(30)

Performance measurements in script languages on Go.

Machine: i5-2520M, 8GB, Windows7

prog time
otto 0m24.848s
anko 0m20.207s
GopherLua 0m1.248s

fib.js

function fib(n) {
    if (n < 2) return n;
    return fib(n - 2) + fib(n - 1);
}

console.log(fib(30));
$ time otto fib.js
832040

real    0m24.848s
user    0m0.015s
sys     0m0.078s

fib.ank

func fib(n) {
    if n < 2 {
      return n
    }
    return fib(n - 2) + fib(n - 1)
}

println(fib(30));
$ time anko fib.ank

832040

real    0m20.207s
user    0m0.030s
sys     0m0.078s

fib.lua

local function fib(n)
    if n < 2 then return n end
    return fib(n - 2) + fib(n - 1)
end

print(fib(30))
$ time glua fib.lua
832040

real    0m1.248s
user    0m0.015s
sys     0m0.187s
Clone this wiki locally