tictoc
npm install node-tictoc
Wrapper around process.hrtime
that lets you have a stack of timers with a simpler api and more useful output:
Usage
var time = ; time; forvar i = 0; i < 1000; i++ // do something time; // prints the elapsed seconds and/or milliseconds
Or a recursive timing solution that takes advantage of the stack:
{ if ! n return; time; ; time; // prints the elapsed time in last-in-first-out (LIFO) order }
If you just want the time values:
time
If you want the profiling string but don't want it console logged automatically:
time.stoc();
Returns an object with the following values for the most recent timer (started with tic
):
seconds
nanos
ms