-1

App.js contains this code:

function add(num1,num2){
    let sum = num1+ num2;
}
let sum = add(2,2);

When I run "time node app.js" In the command line I get the response:

real 0m0.312s

user 0m0.000s

sys 0m0.015s

What does this mean? What is the time flag measuring? How is the runtime calculated? Can you point me to documentation on this flag?

melpomene
  • 84,125
  • 8
  • 85
  • 148

1 Answers1

0

time is a unix command used to determine the duration of execution of a particular command. When run with your node command you will see something like

1.88 real         0.24 user         0.06 sys

at the end of the execution. real is the total elapsed time, user is the time spent in user code and sys is time spent in lernel code. This answer explains it much better.

runnerpaul
  • 5,942
  • 8
  • 49
  • 118