-
Notifications
You must be signed in to change notification settings - Fork 27
Improve performance of npm type #79
Description
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
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
npm ls -g --depth 0 4,61s user 0,83s system 114% cpu 4,735 totalLet 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 totalI 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 totalOnly 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?