Skip to content
Yusuke Inuzuka edited this page Sep 13, 2015 · 9 revisions

fib(35)

Performance measurements in script languages on Go.

Machine: Ubuntu14.04 vCPU:1, Memory:512MB on i5-2520M, 4GB, Windows7

Go version: 1.5

prog time
otto 277.96s
anko 218.47s
agora 129.12s
go-lua 13.48s
GopherLua 9.82s

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
9227465
otto fib.js  277.96s user 0.25s system 99% cpu 4:38.73 total

fib.ank

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

println(fib(30));
% time anko fib.ank
9227465
anko fib.ank  218.47s user 0.20s system 99% cpu 3:39.07 total

fib.agr

fmt := import("fmt")

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

fmt.Println(fib(30))
 % time agora run fib.agr
9227465

= nil (runtime.null)
agora run fib.agr  129.12s user 0.06s system 99% cpu 2:09.47 total

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 go-lua fib.lua
9227465
go-lua fib.lua  13.48s user 0.01s system 99% cpu 13.528 total


 % time glua fib.lua
9227465
glua fib.lua  9.82s user 0.00s system 99% cpu 9.843 total
Clone this wiki locally