Socket
Socket
Sign inDemoInstall

browser-process-hrtime

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

browser-process-hrtime

Shim for process.hrtime in the browser

    1.0.0latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
10,723,270
increased by2.55%

Weekly downloads

Package description

What is browser-process-hrtime?

The browser-process-hrtime package is a browser shim for Node.js's process.hrtime. It allows you to get high-resolution real-time stamps with nanosecond precision, which is useful for performance testing, benchmarking, or tracking the time between events with high accuracy.

What are browser-process-hrtime's main functionalities?

High-resolution time stamps

This feature allows you to measure precise time intervals. The code sample demonstrates how to get the current high-resolution real-time stamp, wait for 1 second using setTimeout, and then get another time stamp to calculate the duration.

const now = require('browser-process-hrtime');
const start = now();
setTimeout(function () {
  const end = now(start);
  console.log('seconds:', end[0]);
  console.log('nanoseconds:', end[1]);
}, 1000);

Other packages similar to browser-process-hrtime

Readme

Source

browser-process-hrtime

Browser shim for Node.js process.hrtime(). See documentation at nodejs.org

This module does not provide the same level of time precision as node.js, but provides a matching API and response format.

usage

Use hrtime independent of environment (node or browser). It will use process.hrtime first and fallback if not present.

const hrtime = require('browser-process-hrtime')
const start = hrtime()
// ...
const delta = hrtime(start)

monkey-patching

You can monkey-patch process.hrtime for your dependency graph like this:

process.hrtime = require('browser-process-hrtime')
const coolTool = require('module-that-uses-hrtime-somewhere-in-its-depths')

note

This was originally pull-requested against node-process, but they are trying to stay lean.

FAQs

Last updated on 23 Sep 2018

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc