Last active
August 29, 2015 14:15
-
-
Save amrnt/b1cae7ddc6c5fb8de814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/robertkrimen/otto" | |
) | |
func main() { | |
vm := otto.New() | |
vm.Run(` | |
function fib(n) { | |
if (n < 2) return n; | |
return fib(n - 2) + fib(n - 1); | |
} | |
console.log(fib(30)); | |
`) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fib(n) { | |
if (n < 2) return n; | |
return fib(n - 2) + fib(n - 1); | |
} | |
console.log(fib(30)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> time go run main.go | |
832040 | |
go run main.go 19.10s user 0.94s system 104% cpu 19.098 total | |
> go build main.go | |
> time ./main | |
832040 | |
./main 18.88s user 0.91s system 105% cpu 18.827 total | |
> time node main.js | |
832040 | |
node main.js 0.05s user 0.02s system 51% cpu 0.141 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment