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

redux-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

redux-performance-plus

A Redux performance measurement middleware, with additional tooling

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Redux Performance Plus

This is a utility and convenience library for measuring Redux action timings. It uses performance-plus to access the browser-based performance API, with support for IE8+.

You can pass a custom action duration limit, where actions exceeding that timing limit (in ms) are passed to an onSlow callback with relevant data.

Example Usage

import { applyMiddleware } from 'redux';
import performance         from 'redux-peformance-plus';

const middlewares = applyMiddleware(
    performance({
        limit: 83,               // 83ms is ~ 5 animation frames
        onSlow: (action) => {
            console.warn(`${action.type} took ${action.duration().toFixed(2)ms}`, {
                mean:          action.mean(),
                sampleSize:    action.samples().length,
                '95th_perc':   action.percentile(0.95)
            })
        }
    })
);
export default middlewares;

Installation

$ npm install redux-performance-plus --save

Configuration

The middleware constructor takes one argument with options.

// Default configuration, no behavior
applyMiddleware(performance());

// Default configuration, log all actions
applyMiddleware(performance({
    onSlow: (action) => {
        console.log(`${action.type} took ${action.duration().toFixed(2)ms}`);
    }
}));

// Custom configuration, log all actions taking over 100ms
applyMiddleware(performance({
    limit: 100,
    onSlow: (action) => {
        console.log(`${action.type} took ${action.duration().toFixed(2)ms}`);
    }
}));

Action Methods

The action data passed to onSlow contains the original action (with type, etc.), along with these methods:

action.type             // unchanged
action.duration();      // latest duration for action type, in ms
action.mean();          // mean duration, in ms
action.sdev();          // standard deviation of mean duration, in ms
action.samples();       // all measures for this action type
action.percentile(0.5); // Percentile duration for recorded samples of this aciton type

Acknowledgements

Keywords

FAQs

Package last updated on 28 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