Skip to content

Commit

Permalink
Merge pull request #2 from gabrielcsapo/master
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
gabrielcsapo committed Jun 10, 2017
2 parents c216e7f + 7df6c51 commit 75c0160
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 168 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "7"
284 changes: 135 additions & 149 deletions README.md
@@ -1,172 +1,158 @@
Test `local-npm` speed
===

Compare the `npm install` times for [local-npm](https://github.com/nolanlawson/local-npm/) versus regular npm, using some popular JavaScript repos.

The test was run on a MacBook Air, with node 5.3.0 and npm 3.3.12. I'm on a slow-ish public WiFi at a café in Brooklyn.
# test-local-npm-speed

[![Build Status](https://travis-ci.org/local-npm/test-local-npm-speed.svg?branch=master)](https://travis-ci.org/local-npm/test-local-npm-speed)

> Compare the `npm install` times for [local-npm](https://github.com/local-npm/local-npm/) versus regular `npm`, using some popular JavaScript repos.
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

- [test-local-npm-speed](#test-local-npm-speed)
- [Summary](#summary)
- [nolanlawson/tiny-queue](#nolanlawsontiny-queue)
- [lodash/lodash](#lodashlodash)
- [substack/node-browserify](#substacknode-browserify)
- [strongloop/express](#strongloopexpress)
- [facebook/react](#facebookreact)
- [gulpjs/gulp](#gulpjsgulp)
- [pouchdb/pouchdb](#pouchdbpouchdb)
- [Full data](#full-data)
- [nolanlawson/tiny-queue](#nolanlawsontiny-queue)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [lodash/lodash](#lodashlodash)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [substack/node-browserify](#substacknode-browserify)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [strongloop/express](#strongloopexpress)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [facebook/react](#facebookreact)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [gulpjs/gulp](#gulpjsgulp)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [pouchdb/pouchdb](#pouchdbpouchdb)
- [local-npm](#local-npm)
- [Regular npm](#regular-npm)
- [Notes](#notes)
- [Reproduce these results](#reproduce-these-results)

<!-- /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
----
# Summary

### nolanlawson/tiny-queue

* 56.92% slower for first `npm install`
* 5.46% faster for second `npm install`
* 43.15% faster after `npm cache clear`

* 45.69% slower for first `npm install`
* 3.22% faster for second `npm install`
* 16.99% faster after `npm cache clear`
### lodash/lodash

* 51.04% slower for first `npm install`
* 61.32% faster for second `npm install`
* 85.44% faster after `npm cache clear`

* 34.26% slower for first `npm install`
* 6.78% faster for second `npm install`
* 2.75% slower after `npm cache clear`
### substack/node-browserify

* 14.43% slower for first `npm install`
* 39.12% faster for second `npm install`
* 90.41% faster after `npm cache clear`

* 33.00% slower for first `npm install`
* 5.64% faster for second `npm install`
* 20.27% slower after `npm cache clear`
### strongloop/express

* 21.40% faster for first `npm install`
* 81.01% faster for second `npm install`
* 92.20% faster after `npm cache clear`

* 29.44% slower for first `npm install`
* 9.86% faster for second `npm install`
* 15.16% faster after `npm cache clear`
### facebook/react

* 14.41% faster for first `npm install`
* 67.13% faster for second `npm install`
* 74.65% faster after `npm cache clear`

* 26.71% slower for first `npm install`
* 8.89% slower for second `npm install`
* 2.76% faster after `npm cache clear`
### gulpjs/gulp

* 75.62% faster for first `npm install`
* 61.89% faster for second `npm install`
* 80.46% faster after `npm cache clear`

* 10.40% slower for first `npm install`
* 6.68% faster for second `npm install`
* 12.54% slower after `npm cache clear`
### pouchdb/pouchdb

* 6.53% slower for first `npm install`
* 38.34% faster for second `npm install`
* 26.73% faster after `npm cache clear`

Full data
----

### nolanlawson/tiny-queue

#### local-npm

* 1st npm install: 0m8.840s
* 2nd npm install: 0m1.679s
* After cache clean: 0m2.008s

#### Regular npm

* 1st npm install: 0m3.808s
* 2nd npm install: 0m1.776s
* After cache clean: 0m3.532s

### lodash/lodash

#### local-npm

* 1st npm install: 5m49.502s
* 2nd npm install: 0m51.192s
* After cache clean: 0m50.634s

#### Regular npm

* 1st npm install: 2m51.100s
* 2nd npm install: 2m12.354s
* After cache clean: 5m47.880s

### substack/node-browserify

#### local-npm

* 1st npm install: 1m47.306s
* 2nd npm install: 0m23.969s
* After cache clean: 0m22.342s

#### Regular npm

* 1st npm install: 1m31.819s
* 2nd npm install: 0m39.369s
* After cache clean: 3m52.876s

### strongloop/express

#### local-npm

* 1st npm install: 1m17.844s
* 2nd npm install: 0m12.225s
* After cache clean: 0m13.667s

#### Regular npm

* 1st npm install: 1m39.033s
* 2nd npm install: 1m4.360s
* After cache clean: 2m55.139s

### facebook/react

#### local-npm

* 1st npm install: 2m56.140s
* 2nd npm install: 1m15.752s
* After cache clean: 1m24.086s

#### Regular npm

* 1st npm install: 3m25.784s
* 2nd npm install: 3m50.467s
* After cache clean: 5m31.755s

### gulpjs/gulp

#### local-npm

* 1st npm install: 0m51.744s
* 2nd npm install: 0m41.765s
* After cache clean: 0m47.815s

#### Regular npm

* 1st npm install: 3m32.214s
* 2nd npm install: 1m49.591s
* After cache clean: 4m4.641s

### pouchdb/pouchdb

#### local-npm

* 1st npm install: 7m31.151s
* 2nd npm install: 4m7.253s
* After cache clean: 5m2.884s

#### Regular npm

* 1st npm install: 7m1.702s
* 2nd npm install: 6m40.994s
* After cache clean: 6m53.363s

Notes
---
* 8.16% slower for first `npm install`
* 6.13% faster for second `npm install`
* 12.62% faster after `npm cache clear`

# Full data

# nolanlawson/tiny-queue
## local-npm
* 1st npm install: 0m2.392s
* 2nd npm install: 0m1.263s
* After cache clean: 0m2.447s
## Regular npm
* 1st npm install: 0m1.299s
* 2nd npm install: 0m1.305s
* After cache clean: 0m2.948s
# lodash/lodash
## local-npm
* 1st npm install: 1m22.140s
* 2nd npm install: 0m48.855s
* After cache clean: 1m19.177s
## Regular npm
* 1st npm install: 0m53.995s
* 2nd npm install: 0m52.407s
* After cache clean: 1m17.000s
# substack/node-browserify
## local-npm
* 1st npm install: 0m41.307s
* 2nd npm install: 0m26.133s
* After cache clean: 0m49.842s
## Regular npm
* 1st npm install: 0m27.677s
* 2nd npm install: 0m27.695s
* After cache clean: 0m39.738s
# strongloop/express
## local-npm
* 1st npm install: 0m19.571s
* 2nd npm install: 0m13.149s
* After cache clean: 0m16.645s
## Regular npm
* 1st npm install: 0m13.810s
* 2nd npm install: 0m14.587s
* After cache clean: 0m19.619s
# facebook/react
## local-npm
* 1st npm install: 2m30.568s
* 2nd npm install: 1m54.844s
* After cache clean: 2m39.366s
## Regular npm
* 1st npm install: 1m50.349s
* 2nd npm install: 1m44.638s
* After cache clean: 2m43.893s
# gulpjs/gulp
## local-npm
* 1st npm install: 0m40.063s
* 2nd npm install: 0m36.125s
* After cache clean: 1m4.591s
## Regular npm
* 1st npm install: 0m35.895s
* 2nd npm install: 0m38.711s
* After cache clean: 0m56.494s
# pouchdb/pouchdb
## local-npm
* 1st npm install: 2m37.697s
* 2nd npm install: 2m2.765s
* After cache clean: 2m40.102s
## Regular npm
* 1st npm install: 2m24.823s
* 2nd npm install: 2m10.778s
* After cache clean: 3m3.219s

# 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` &ndash; 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
---
# 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.
**Warning:** the test will override your local `~/.npmrc` file! So you may want to do `npmrc -c testing && npmrc testing` beforehand.
33 changes: 20 additions & 13 deletions package.json
@@ -1,15 +1,22 @@
{
"name": "test-local-npm-speed",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "sh test.sh"
},
"keywords": [],
"author": "Nolan Lawson <nolan@nolanlawson.com>",
"dependencies": {
"local-npm": "1.4.9"
},
"license": "Apache-2"
"name": "test-local-npm-speed",
"version": "1.0.0",
"description": "Compare the `npm install` times for [local-npm](https://github.com/local-npm/local-npm/) versus regular `npm`, using some popular JavaScript repos.",
"main": "index.js",
"scripts": {
"test": "sh test.sh"
},
"keywords": [
"local-npm",
"speed",
"test"
],
"author": "Nolan Lawson <nolan@nolanlawson.com>",
"contributors": [
"Gabriel J. Csapo <gabecsapo@gmail.com>"
],
"dependencies": {
"local-npm": "^2.0.1"
},
"license": "Apache-2"
}
3 changes: 1 addition & 2 deletions print-summary.py
@@ -1,9 +1,8 @@
#!/usr/bin/env python

import re

s = open('results.md', 'r').read()
times = re.compile('### (\S+).*?local-npm.*?(\d+m.*?s).*?(\d+m.*?s).*?(\d+m.*?s).*?Regular npm.*?(\d+m.*?s).*?(\d+m.*?s).*?(\d+m.*?s)', re.DOTALL).findall(s)
times = re.compile('#.?(\S+).*?local-npm.*?(\d+m.*?s).*?(\d+m.*?s).*?(\d+m.*?s).*?Regular npm.*?(\d+m.*?s).*?(\d+m.*?s).*?(\d+m.*?s)', re.DOTALL).findall(s)

def diffIt(first, second):
first = re.findall('([\d\.]+)m([\d\.]+)s', first)[0]
Expand Down
9 changes: 5 additions & 4 deletions test.sh
@@ -1,11 +1,10 @@
#!/usr/bin/env bash
#!/bin/bash

REPOS='nolanlawson/tiny-queue lodash/lodash substack/node-browserify strongloop/express facebook/react gulpjs/gulp pouchdb/pouchdb'
#REPOS='nolanlawson/tiny-queue'

RESULTS_FILE=$(pwd)/results.md

function timeIt () { { time npm install > /dev/null 2>&1 ; } 2>&1 | grep real | awk '{print $2}' ; }
timeIt() { { time npm install > /dev/null 2>&1 ; } 2>&1 | grep real | awk '{print $2}' ; }

rm -fr $RESULTS_FILE workspace
touch $RESULTS_FILE
Expand Down Expand Up @@ -47,4 +46,6 @@ for repo in $REPOS; do

done

cat $RESULTS_FILE
cat $RESULTS_FILE

python print-summary.py

0 comments on commit 75c0160

Please sign in to comment.