Bare Docs
ReferenceBareModules

bare-hrtime

High-resolution timers for JavaScript

Documented against v2.1.2
stable

bare-hrtime — High-resolution timers for JavaScript. It is a native addon.

npm i bare-hrtime

Usage

const hrtime = require('bare-hrtime')

hrtime() // returns [seconds, nanoseconds]
hrtime.bigint() // returns nanoseconds

API

Functions

hrtime(prev?: ArrayLike<number>): [seconds: number, nanoseconds: number]

Returns the current high-resolution time as a [seconds, nanoseconds] tuple. If prev (a previous hrtime() result) is given, returns the elapsed time since it instead.

Parameters

ParameterTypeDefaultDescription
prev?ArrayLike<number>—A previous hrtime() result to compute the elapsed time since.

hrtime.bigint(): bigint

Returns the current high-resolution time in nanoseconds as a bigint. The value is relative to an arbitrary point in the past and is only meaningful when compared against another reading.

See also

Last updated on

Was this helpful?

On this page