Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I time my npm install?

I am trying to see how much time npm install takes to complete installing all my dependencies. Is there a way for me to time this process, natively (in npm) or using some third party plugin? I've tried * npm i --verbose * npm i --silly * slow-deps (A third party lib that analyzes your npm packages)

slow-deps gave me a decent result, but I am not sure about it's accuracy, as it doesn't run as part of the npm install process.

Is there any other way to accurately time-profile the npm install process? I'm looking for an output like this (output screenshot from Yarn):

enter image description here

like image 830
nikjohn Avatar asked Oct 12 '16 04:10

nikjohn


People also ask

How much time does npm install take?

npm install : 4.1 minutes per run. yarn : 2 minutes for the first run and 1 minute for subsequent runs.

Why do I have to do npm install every time?

npm install simply reads your package. json file, fetches the packages listed there from (usually) https://www.npmjs.com/ , and sometimes engages in the build steps for those packages. So you only have to run npm install when you change your package. json file, and need to fetch new dependencies.


2 Answers

Thanks for your help. I have come across a few utilities for this:

  • The time utility mentioned by @JJJ in the comments section.
  • Paypal's gnomon package, that updates timestamps to everything.
like image 59
nikjohn Avatar answered Oct 09 '22 21:10

nikjohn


Use time linux command and have the following command:

time npm install

Also according to https://www.commandlinux.com/man-page/man1/time.1.html

Users of the bash shell need to use an explicit path in order to run the external time command and not the shell builtin variant.

so your command may be (I am a macOS user and I am using the below command):

/usr/bin/time npm install

The output of this command (at the last line) would be something like this:

153.96 real        67.63 user        34.12 sys

so basically what you are looking at is the real number that are in seconds. To the above example the time taken is:

153.96s
like image 33
John Skoumbourdis Avatar answered Oct 09 '22 20:10

John Skoumbourdis