# hirestime

> thin wrapper around process.hrtime

Latest version **7.0.4** (published 2024-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install hirestime
pnpm add hirestime
yarn add hirestime
bun add hirestime
```

## Health

**Score 30/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.4 |
| Published | 2024-02-15 |
| First published | 2013-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0 |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Manuel Ernst |
| Maintainers | zaphod1984 |
| Keywords | hrtime, hirestimer, milliseconds, seconds, nanoseconds, high resolution timer, profiling, profiler, timing, measurement |

## Links

- npm: https://www.npmjs.com/package/hirestime
- Repository: https://github.com/seriousManual/hirestime
- Homepage: https://github.com/seriousManual/hirestime#readme
- Issues: https://github.com/seriousManual/hirestime/issues
- npm.io page: https://npm.io/package/hirestime

## Recent versions

- 7.0.4 (latest) — 2024-02-15
- 7.0.3 — 2022-10-27
- 7.0.2 — 2022-10-27
- 7.0.1 — 2022-09-20
- 7.0.0 — 2022-09-16
- 6.1.0 — 2020-08-17
- 6.0.1 — 2020-03-02
- 6.0.0 — 2020-02-28
- 5.0.6 — 2020-02-24
- 5.0.5 — 2020-02-18
- 5.0.4 — 2020-02-18
- 5.0.3 — 2020-02-18
- 5.0.2 — 2020-02-18
- 5.0.1 — 2020-02-18
- 5.0.0 — 2020-02-18
- … 23 more at https://npm.io/package/hirestime/versions

## README

# hirestime

`hirestime` is a thin wrapper around the common time measuring APIs (node and the browser).
Uses `process.hrtime()` on node, the [performance API](https://developer.mozilla.org/de/docs/Web/API/Performance/now) in the browser and falls back to `Date` if neither is available.

## Installation

````bash
npm install hirestime
````

## hirestime()
returns a function:

### returnedFunction()
Returns the elapsed time since the call of `hirestime` in milliseconds.    

## Examples

By default the time is measured in milliseconds:
````javascript
import hirestime from 'hirestime'

//startpoint of the time measurement
const getElapsed = hirestime()

setTimeout(_ => {
    //returns the elapsed milliseconds
    console.log(getElapsed())
}, 1000)
````

Specify the unit:
 ````javascript
import hirestime from 'hirestime'

//startpoint of the time measurement
const getElapsed = hirestime()

setTimeout(_ => {
    //returns the elapsed seconds
    console.log(getElapsed.s())
    console.log(getElapsed.seconds())

    //returns the elapsed milliseconds
    console.log(getElapsed.ms())
    console.log(getElapsed.milliseconds())

    //returns the elapsed nanoseconds
    console.log(getElapsed.ns())
    console.log(getElapsed.nanoseconds())
}, 1000)
````

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