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

performance-plus

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

performance-plus

A utility and convenience library for the browser-based performance API, with support for IE8+

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Performance Plus

This is a utility and convenience library for the browser-based performance API, with support for IE8+ and zero dependencies.

The performance API allows for sub-millisecond, high-resolution timestamp measurements. This library adds some basic statistical helpers while collecting that data in slightly better style. In browsers below Internet Explorer 10, the performance API is unsupported. This library pseudo-fills that hole with plain old objects to deliver the same interface, just not at sub-millisecond resolution.

Example Usage

import perf from 'performance-plus';

var action = 'foobar';
perf.start(action);     // capture start timestamp
func();                 // this thing takes some time
perf.end(action);       // capture ending timestamp
// repeat the above loop a few times

console.log(`[perf] action ${action}`,
    `took ${perf.duration(action).toFixed(2)}ms`, {
    mean:         perf.mean(action),
    sdev:         perf.sdev(action),
    sampleSize:   perf.getEntriesByName(action).length,
    '95th_perc':  perf.percentile(action, 0.95)
});
// It can also measure FPS rendering
perf.onFPS((fps, time) => {
    console.log(`It is now ${time} and we are rendering at ${fps} frames per second`);
}, 2000); // measure and call every 2 seconds

Installation

$ npm install performance-plus

Methods

Commonly used methods:

perf.now();                     // high-res timestamp
perf.start('something');
perf.end('something');
perf.duration('something');     // in ms
perf.mean('something');         // in ms
perf.sdev('something');         // in ms
perf.getEntriesByName('something'); // all measures for this name
perf.getEntryByName('something');   // last measure for this name

Complete methods with JSDocs

Acknowledgements

Keywords

FAQs

Package last updated on 26 Jan 2018

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