Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

w3c-hr-time

Package Overview
Dependencies
Maintainers
6
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

w3c-hr-time

An implementation of the W3C High Resolution Time Level 2 specification.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.6M
decreased by-45.33%
Maintainers
6
Weekly downloads
 
Created

What is w3c-hr-time?

The w3c-hr-time npm package provides a high-resolution time API, which is a JavaScript implementation of the High Resolution Time specification by the W3C. It allows developers to measure time intervals with sub-millisecond precision, which is useful for performance monitoring and benchmarking.

What are w3c-hr-time's main functionalities?

High-Resolution Time

This feature allows you to measure the time taken by a block of code to execute with high precision. The `performance.now()` method returns a timestamp in milliseconds, accurate to a thousandth of a millisecond.

const { performance } = require('w3c-hr-time');
const start = performance.now();
// Some code to measure
const end = performance.now();
console.log(`Execution time: ${end - start} milliseconds`);

Performance Mark

This feature allows you to create named marks in the performance timeline and measure the duration between them. This is useful for more complex performance monitoring scenarios.

const { performance } = require('w3c-hr-time');
performance.mark('start');
// Some code to measure
performance.mark('end');
performance.measure('MyMeasurement', 'start', 'end');
const measure = performance.getEntriesByName('MyMeasurement')[0];
console.log(`Execution time: ${measure.duration} milliseconds`);

Other packages similar to w3c-hr-time

FAQs

Package last updated on 06 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc