安装
npm install time-span
yarn add time-span
pnpm add time-span
bun add time-span
README

time-span

Simplified high resolution timing

Uses process.hrtime in Node.js and performance.now in browsers (accurate to 5 microseconds).

Install

$ npm install time-span

Usage

import timeSpan from 'time-span';

const end = timeSpan();

timeConsumingFn();

console.log(end());
//=> 1745.3186

console.log(end.rounded());
//=> 1745

console.log(end.seconds());
//=> 1.7453186

API

const end = timeSpan()

Returns a function, that when called, returns the time difference.

end()

Elapsed milliseconds.

end.rounded()

Elapsed milliseconds rounded.

end.seconds()

Elapsed seconds.

end.nanoseconds()

Elapsed nanoseconds.

版本列表
5.1.0 2022-06-26
5.0.0 2021-04-14
4.0.0 2020-03-12
3.1.0 2019-04-05
3.0.0 2019-03-08
2.0.0 2017-05-23
1.0.0 2015-12-10