Skip to content
This repository was archived by the owner on Feb 14, 2021. It is now read-only.

Improve performance of npm type #79

Open
frdmn opened this issue Aug 19, 2016 · 0 comments
Open

Improve performance of npm type #79

frdmn opened this issue Aug 19, 2016 · 0 comments

Comments

@frdmn
Copy link
Collaborator

frdmn commented Aug 19, 2016

I noticed that my npm borkfile takes about two or three minutes to finish all the the assertions. The culprit of this is line 19 in npm.sh, as well as line 22:

list=$(bake npm ls -g --depth 0)

outdated=$(bake npm outdated -g) 

This first command alone takes about 4,5 seconds to finish:

time npm ls -g --depth 0
/Users/jonas/.npm-packages/lib
├── bower@1.7.9
├── canibekikked@1.5.1
├── cloudflare-cli@1.6.0
├── coffee-script@1.10.0
├── cordova@6.3.0
├── diff-so-fancy@0.11.1
├── electron-prebuilt@1.2.5
├── express-generator@4.13.4
├── ghost-to-md@1.2.0
├── gifify@2.1.6
├── git-hours@1.3.0
├── grunt@1.0.1
├── grunt-cli@1.2.0
├── gulp@3.9.1
├── gulp-cli@1.2.1
├── hastebin@0.0.1
├── hubot@2.19.0
├── init.js@1.2.4
├── json@9.0.4
├── ms@0.7.1
├── npm@3.10.5
├── npm-check@5.0.3
├── npm-check-updates@2.6.7
├── ntmjs@0.0.61
├── prettydiff@99.0.1
├── prettyjson@1.1.3
├── psi@2.0.4
├── sitespeed.io@3.11.5
├── stringstream@0.0.5
├── tlstools@1.3.1
├── twitgrab@1.0.0
└── updatr@0.1.1

npm ls -g --depth 0  4,61s user 0,83s system 114% cpu 4,735 total

Let alone, a single assertion using Bork about 11 seconds:

time bork do ok npm diff-so-fancy
ok: npm diff-so-fancy
bork do ok npm diff-so-fancy  10,25s user 2,13s system 102% cpu 12,128 total

I would love to improve this somehow but I am not quite sure how to do it properly. I did some discussion with @bcomnes in the IRC channel yesterday and he had the idea to maybe just use ls on the global node_modules, something like ls -1 $(npm config get prefix)/lib/node_module.

When I run some timings on this, it takes about 0,33 seconds for both ls and npm to finish:

time ls -1 $(time npm config get prefix)/lib/node_modules
npm config get prefix  0,30s user 0,04s system 103% cpu 0,331 total
bower
canibekikked
cloudflare-cli
coffee-script
cordova
diff-so-fancy
electron-prebuilt
express-generator
ghost-to-md
gifify
git-hours
grunt
grunt-cli
gulp
gulp-cli
hastebin
hubot
init.js
json
ms
npm
npm-check
npm-check-updates
ntmjs
prettydiff
prettyjson
psi
sitespeed.io
stringstream
tlstools
twitgrab
updatr
ls -G -1 $(time npm config get prefix)/lib/node_modules  0,00s user 0,00s system 75% cpu 0,003 total

Only downside here is that we don't have the version information for each module. Also I have no clue how to replicate or improve the npm outdated command.

Do you guys have any ideas / feedback on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants