Yarn速かった

Yarn 速かった

Yarn とは

https://code.facebook.com/posts/1840075619545360

Facebook, Google, Tilde, Exponentの人たちが作ったnpmクライアント。 npm install の代わりに使える。

http://qiita.com/mizchi/items/1002fde0de10e7c54fb2

詳しくはこの辺

実行時間測ってみた

試しに業務レポジトリで npm installyarn を比べてみた

  • dependencies + devDependencies : 70 個
  • npm-shrinkwrap.json : 22298 行
  • 元の node_modules : 22 KB

npm install

303 sec

$ rm -rf node_modules
$ npm cache clean
$ time npm install
(中略)
npm install  268.92s user 71.13s system 93% cpu 6:02.97 total

キャッシュなしで yarn

103 sec

 $ rm -rf ~/.yarn-cache
 $ rm -rf ~/.yarn
 $ rm -rf node_modules
 $ time yarn
yarn install v0.15.1
error npm-shrinkwrap.json found. This will not be updated or respected. See [TODO] for more information.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
warning benchmark@1.0.0: The engine "rhino" appears to be invalid.
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 102.55s.
yarn  56.30s user 27.98s system 81% cpu 1:42.99 total

キャッシュありで yarn

37 sec

$ rm -rf node_modules
$ time yarn
yarn install v0.15.1
error npm-shrinkwrap.json found. This will not be updated or respected. See [TODO] for more information.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
warning benchmark@1.0.0: The engine "rhino" appears to be invalid.
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 36.91s.
yarn  21.12s user 13.32s system 92% cpu 37.299 total

はえ〜