JSPM

clockit

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3019
  • Score
    100M100P100Q117999F
  • License MIT

Simple high resolution timer for node

Package Exports

  • clockit

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clockit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm

clockit

Simple high resolution timer for node

Wraps process.hrtime() in a simple to use interface. No need to multiply and divide to get desired measurement units.

Timer precision is a nanosecond.

*Note: requires Node.js 4 or later.

Install

npm install --save clockit

Usage

const clockit = require('clockit');

var timer = clockit.start();
// ...
var ms = timer.ms; // time passed in milliseconds
var us = timer.us; // time passed in microseconds
var ns = timer.ns; // time passed in nanoseconds

Since time is measured in nanoseconds, ns returns an integer while us and ms return floating point numbers without rounding.

These timer properties return the elapsed time since the start() call. This means that two consecuritve reads of ns for example will return different values taking into account the time between the two calls.