hrtime-measure
This module measures the execution time of javascript operations.
Example
This example starts the measurement in the app.js file.
const measure = ; // start measurementmeasurestart'AnyName';
And continues the measurement in the middleware.js file.
const measure = ; // set the steps by measure name and step title.measure;measure;measure; // stop measurement measure name.measure;
Console Output
Total execution time "AnyName": ~ 0s 83.52 ms1. 0s 0.09 ms app.js:http_io2. 0s 13.13 ms 3. 0s 70.11 ms middleware.js:initNumeral4. 0s 0.19 ms middleware.js:return
Group Steps
const measure = ; // start measurementmeasurestart'AnyName';measure;measure;measure;measure;
Console Output
Total execution time "AnyName": ~ 0s 83.52 ms1. 0s 0.09 ms prepare loop2. 0s 70.13 ms loop3. 0s 13.11 ms end loop
Install
npm install hrtime-measure --save
API
start(label)
Start the measurement and give the name for the new timer. This will identify the timer; use the same name when calling measure.end() to stop the timer.
step(label,[title])
Step set a timesplit by label
with any optional title
.
end(label,[title],[print])
Stop the measurement and return the ouput as a string. If the optional parameter print
is set to true, the time will output to the console.
disable()
With this function, the measurement can be turned off in production.