hitime
⏰ Hi-res timer for Node, wrapped in some pretty helpers.
Install
npm install -S hitime
Use
To get a simple high resolution timestamp:
var hitime = ; var timestamp = ;
This will return a decimal number, in milliseconds (so you can still do mental math), accurate to the nanosecond, using Node's native process.hrtime
. This is a relative time, measured from the time that the module was loaded.
You can compare two timestamps with regular math, because they are just numbers:
var a = ;var b = ; var duration = b - a;
Using named timers
Similarly to Chrome's console.time
, this module gives you named timers, so you can keep easier track of various tasks.
var timer = hitime; timerstart'async work'; ;
Any timers that have ben registered will appear in the report, containing the following values:
start
: the relative start time of the timerend
: the relative end time of the timerduration
: the total time for the timer