Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

time-span

sindresorhus4.8mMIT5.1.0TypeScript support: included

Simplified high resolution timing

time, span, elapsed, process, hrtime, highres, timing, perf, performance, bench, benchmark, profiling, measure, seconds, milliseconds, nanoseconds

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.