From 1ddbfd1755851c2afabe3f9366ece9a684b1b2a8 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Fri, 9 Jun 2017 21:04:50 -0700 Subject: [PATCH 1/3] updates readme with current information bumps local-npm version fixes print-summary.py file adds print-summary funcation at the end of test.sh --- .travis.yml | 3 + README.md | 280 ++++++++++++++++++++++------------------------- package.json | 33 +++--- print-summary.py | 3 +- test.sh | 5 +- 5 files changed, 160 insertions(+), 164 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0fe294a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: node_js +node_js: + - "7" diff --git a/README.md b/README.md index ec40a1b..972fa2d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,44 @@ -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. +# 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. + + + +- [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) + + 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. @@ -9,154 +46,104 @@ I started off with a small repo of mine, `nolanlawson/tiny-queue`, then moved on **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` - -### substack/node-browserify - -* 14.43% slower for first `npm install` -* 39.12% faster for second `npm install` -* 90.41% faster 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` - -### facebook/react - -* 14.41% faster for first `npm install` -* 67.13% faster for second `npm install` -* 74.65% 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` - -### 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 - +* 34.26% slower for first `npm install` +* 6.78% faster for second `npm install` +* 2.75% slower after `npm cache clear` ### 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 - +* 33.00% slower for first `npm install` +* 5.64% faster for second `npm install` +* 20.27% slower after `npm cache clear` ### 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 - +* 29.44% slower for first `npm install` +* 9.86% faster for second `npm install` +* 15.16% faster after `npm cache clear` ### 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 - +* 26.71% slower for first `npm install` +* 8.89% slower for second `npm install` +* 2.76% faster after `npm cache clear` ### 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 - +* 10.40% slower for first `npm install` +* 6.68% faster for second `npm install` +* 12.54% slower after `npm cache clear` ### 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. @@ -164,9 +151,8 @@ Also, repos tested later in the test may benefit from a slight boost, if they sh 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. \ No newline at end of file +**Warning:** the test will override your local `~/.npmrc` file! So you may want to do `npmrc -c testing && npmrc testing` beforehand. diff --git a/package.json b/package.json index 678d4b6..908844f 100644 --- a/package.json +++ b/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 ", - "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 ", + "contributors": [ + "Gabriel J. Csapo " + ], + "dependencies": { + "local-npm": "^2.0.1" + }, + "license": "Apache-2" } diff --git a/print-summary.py b/print-summary.py index fa443c6..43e2e13 100644 --- a/print-summary.py +++ b/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] diff --git a/test.sh b/test.sh index 4c079f4..c6ee108 100755 --- a/test.sh +++ b/test.sh @@ -1,7 +1,6 @@ #!/usr/bin/env 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 @@ -47,4 +46,6 @@ for repo in $REPOS; do done -cat $RESULTS_FILE \ No newline at end of file +cat $RESULTS_FILE + +python print-summary.py From 29e2dc329e5477216e00bbaf2c80d66a1ad53d07 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Fri, 9 Jun 2017 21:07:34 -0700 Subject: [PATCH 2/3] adds build status and removes some readme text --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 972fa2d..d2b3422 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 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. @@ -40,8 +42,6 @@ -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. - 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. From 7df6c51797bef8486a201e2690b5f766a5c465d0 Mon Sep 17 00:00:00 2001 From: Gabriel Csapo Date: Fri, 9 Jun 2017 21:13:50 -0700 Subject: [PATCH 3/3] fixes test.sh --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index c6ee108..31b6c57 100755 --- a/test.sh +++ b/test.sh @@ -1,10 +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' 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