Home

Awesome

test-local-npm-speed

Build Status

Compare the npm install times for local-npm versus regular npm, using some popular JavaScript repos.

<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 --> <!-- /TOC -->

I started off with a small repo of mine, nolanlawson/tiny-queue, then moved on to some popular libraries like lodash/lodash and facebook/react. In each case, I'm just cloning the code from Github and running npm install.

TLDR: Regular npm is faster for the first npm install, but afterwards local-npm is always faster, even after npm cache clear. Sometimes it's even 2x or 3x faster (e.g. 1m15.752s vs 3m50.467s to install facebook/react the 2nd time). This is kind of the point of local-npm: it gets faster the more you run it, because it aggressively caches everything.

Summary

nolanlawson/tiny-queue

lodash/lodash

substack/node-browserify

strongloop/express

facebook/react

gulpjs/gulp

pouchdb/pouchdb

Full data

nolanlawson/tiny-queue

local-npm

Regular npm

lodash/lodash

local-npm

Regular npm

substack/node-browserify

local-npm

Regular npm

strongloop/express

local-npm

Regular npm

facebook/react

local-npm

Regular npm

gulpjs/gulp

local-npm

Regular npm

pouchdb/pouchdb

local-npm

Regular npm

Notes

The test is a little unfair, because my local-npm has already downloaded all the metadata, but this is a typical use-case for local-npm. (It replicates the npm metadata on first run, which can take a few hours.) I did clear out the tarballs before the test, though.

Also, repos tested later in the test may benefit from a slight boost, if they share any modules with a previous repo. But again, this is a typical use-case for local-npm – the more you use it, the more that common tarballs will be pre-cached.

I find it interesting that local-npm is faster even after the second npm install, which is when npm's cache is supposed to kick in. This suggests that npm is not caching as aggressively as it could be.

Reproduce these results

First, npm install -g local-npm && local-npm. Then just clone this repo and run npm test. The python script can print a summary afterwards.

Warning: the test will override your local ~/.npmrc file! So you may want to do npmrc -c testing && npmrc testing beforehand.