Skip to content

Instantly share code, notes, and snippets.

@nobonobo
Last active January 17, 2017 03:46
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 nobonobo/8bfcebdefeb0c2eef909dc2ad2269280 to your computer and use it in GitHub Desktop.
Save nobonobo/8bfcebdefeb0c2eef909dc2ad2269280 to your computer and use it in GitHub Desktop.
nodejsとGo製jsエンジンとの比較ベンチ

nodejsとGo製jsエンジンとの比較ベンチ

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

real	1m37.071s
user	2m17.120s
sys	0m3.596s

$ time go-duk fib.js 
9227465

real	0m7.410s
user	0m7.400s
sys	0m0.000s

$ time goja fib.js 
2017/01/17 10:30:21 9227465

real	0m5.620s
user	0m5.616s
sys	0m0.004s

$ time nodejs fib.js
9227465

real	0m0.202s
user	0m0.128s
sys	0m0.000s
@nobonobo
Copy link
Author

nobonobo commented Jan 17, 2017

結果: nodejs>>>goja>go-duk>>otto
v8の再帰最適化が恐ろしいほど早かった。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment