Skip to content
Yusuke Inuzuka edited this page Aug 20, 2016 · 9 revisions

fib(35)

Machine: Windows7 64bit CPU:2, Memory:8GB

Go version: 1.7

Script languages implemented in pure Go

Other script languages

  • lua5.1.4
  • Python3.4
prog time
anko 182.73s
otto 173.32s
go-lua 8.13s
Python3.4 5.84s
GopherLua 5.40s
lua5.1.4 1.71s
http://g.gravizo.com/g?@gravizosvg{"svg":{"@height":"420","@width":"420","path":[{"@d":"M%2010%20372%20l%20370%200","@stroke":"black","@stroke-width":"1","@fill":"none"},{"@d":"M380%20372%20l%200%20-370","@stroke":"black","@stroke-width":"1","@fill":"none"}],"g":[{"@stroke":"black","@stroke-width":"3","@fill":"black","rect":[{"@id":"r-anko","@x":"20","@y":"4","@width":"10","@height":"366"},{"@id":"r-otto","@x":"80","@y":"23","@width":"10","@height":"347"},{"@id":"r-golua","@x":"140","@y":"354","@width":"10","@height":"16"},{"@id":"r-python34","@x":"200","@y":"358","@width":"10","@height":"12"},{"@id":"r-lua","@x":"320","@y":"366","@width":"10","@height":"4"}]},{"@stroke":"red","@stroke-width":"3","@fill":"red","rect":[{"@id":"r-gopher-lua","@x":"260","@y":"359","@width":"10","@height":"11"}]},{"@font-size":"15","@font-family":"sans-serif","@fill":"black","@stroke":"none","@text-anchor":"middle","text":[{"@x":"20","@y":"390","@dy":"15","$":"anko"},{"@x":"80","@y":"390","$":"otto"},{"@x":"140","@y":"390","@dy":"15","$":"go-lua"},{"@x":"200","@y":"390","$":"python34"},{"@x":"260","@y":"390","@dy":"15","$":"GopherLua"},{"@x":"320","@y":"390","$":"lua5.1.4"},{"@x":"390","@y":"370","$":"0s"},{"@x":"390","@y":"350","$":"10s"},{"@x":"390","@y":"310","$":"30s"},{"@x":"390","@y":"250","$":"60s"},{"@x":"390","@y":"130","$":"120s"},{"@x":"390","@y":"10","$":"180s"}]}]}}

fib.js

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

console.log(fib(35));
% time otto fib.js
9227465
otto fib.js  0.01s user 0.00s system 0% cpu 2:53.32 total

fib.ank

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

println(fib(35));
% time anko fib.ank
9227465
anko fib.ank  0.00s user 0.23s system 0% cpu 3:02.73 total

fib.lua

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

print(fib(35))
% time go-lua fib.lua
9227465
go-lua fib.lua  0.00s user 0.08s system 0% cpu 8.129 total

% time glua fib.lua
9227465
glua fib.lua  0.01s user 0.00s system 0% cpu 5.403 total

% lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
 % time lua fib.lua
9227465
lua fib.lua  0.00s user 0.00s system 0% cpu 1.714 total

fib.py

def fib(n)
    if n < 2:
      return n
    return fib(n - 2) + fib(n - 1)

print(fib(35))
% python34 --version
Python 3.4.3
 % time python34 fib.py
9227465
python34 fib.py  0.00s user 0.07s system 1% cpu 5.846 total
Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy