# time-span

> Simplified high resolution timing

Latest version **5.1.0** (published 2022-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install time-span
pnpm add time-span
yarn add time-span
bun add time-span
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2022-06-26 |
| First published | 2015-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 83 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | time, span, elapsed, process, hrtime, highres, timing, perf, performance, bench, benchmark, profiling, measure, seconds, milliseconds, nanoseconds |

## Links

- npm: https://www.npmjs.com/package/time-span
- Repository: https://github.com/sindresorhus/time-span
- Homepage: https://github.com/sindresorhus/time-span#readme
- Issues: https://github.com/sindresorhus/time-span/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/time-span

## Dependencies (1)

- [convert-hrtime](https://npm.io/package/convert-hrtime.md) ^5.0.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 5.1.0 (latest) — 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

## README

# time-span

> Simplified high resolution timing

Uses [`process.hrtime`](https://nodejs.org/api/process.html#processhrtimebigint) in Node.js and [`performance.now`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) in browsers ([accurate to 5 microseconds](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp)).

## Install

```
$ npm install time-span
```

## Usage

```js
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.

---
_Source: https://npm.io/package/time-span · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
