A small collection of useful functions to work with Node.js
process.hrtime
values.
hrtime-utils
is a tiny module that exports a few useful functions that you can use to convert the value returned from process.hrtime()
to a time unit.
$ npm i @dnlup/hrtime-utils
const {
hrtime2ns,
hrtime2us,
hrtime2ms,
hrtime2
} = require('@dnlup/hrtime-utils')
const time = process.hrtime()
hrtime2ns(time) // time in nanoseconds
hrtime2us(time) // time in microseconds
hrtime2ms(time) // time in milliseconds
hrtime2s(time) // time in seconds
const delta = process.hrtime(time)
hrtime2ns(delta) // delta in nanoseconds
hrtime2us(delta) // delta in microseconds
hrtime2ms(delta) // delta in milliseconds
hrtime2s(delta) // delta in seconds
-
time
<integer[]
> The return value of aprocess.hrtime()
call -
Returns
<number>
This function converts time
to nanoseconds.
-
time
<integer[]
> The return value of aprocess.hrtime()
call -
Returns
<number>
This function converts time
to microseconds.
-
time
<integer[]
> The return value of aprocess.hrtime()
call -
Returns
<number>
This function converts time
to milliseconds.
-
time
<integer[]
> The return value of aprocess.hrtime()
call -
Returns
<number>
This function converts time
to seconds.