Skip to content

Instantly share code, notes, and snippets.

@innomon
Created November 21, 2016 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save innomon/a418150127bf99dff67fb95a81b9e378 to your computer and use it in GitHub Desktop.
Save innomon/a418150127bf99dff67fb95a81b9e378 to your computer and use it in GitHub Desktop.
Fibonacci Benchmark

Lua v/s JavaScript

Based on lua benchmarks, I conducted my own tests.

Table 1. Benchmark Result
Program time

fib.go

0m0.068s

fib.c

0m0.076s

fib.js

0m0.180s

fib.lua

0m1.372s

Commands
time node  fib.js
time lua   fib.lua
go build fib.go
time ./fib
gcc fib.c -o fibc
time ./fibc
#include<stdio.h>
int fib(int n) {
return (n < 2)? n: (fib(n - 2) + fib(n - 1));
}
int main() {
printf("%d\n",fib(35));
}
package main
import "fmt"
func fib(n int) int {
if n < 2 {return n }
return fib(n - 2) + fib(n - 1)
}
func main() {
fmt.Println(fib(35))
}
function fib(n) {
if (n < 2) return n;
return fib(n - 2) + fib(n - 1);
}
console.log(fib(35));
local function fib(n)
if n < 2 then return n end
return fib(n - 2) + fib(n - 1)
end
print(fib(35))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment