npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

speedact

v1.0.8

Published

A modern library for measuring React component performance

Downloads

128

Readme

SpeedAct

A simple and efficient library for monitoring React component performance.

Installation

npm install speedact

Quick Start

Wrapper Component

import { PerformanceMonitor } from "speedact";

function App() {
  return (
    <PerformanceMonitor
      componentName="MyComponent"
      logToConsole={true}
      threshold={16} // Alert if render > 16ms
      onMetricsUpdate={(metrics) => console.log(metrics)}
    >
      <MyComponent />
    </PerformanceMonitor>
  );
}

API Reference

PerformanceMonitor

Available props:

  • children: ReactNode - Child components to be monitored
  • componentName?: string - Component name (default: "PerformanceMonitor")
  • onMetricsUpdate?: (metrics: PerformanceMetrics) => void - Callback called on each render
  • logToConsole?: boolean - Automatic console logging (default: false)
  • threshold?: number - Threshold in ms for alerts (default: 16)
  • enabled?: boolean - Enable/disable monitoring (default: true)
  • maxSamples?: number - Maximum renders tracked (default: 100)

PerformanceMetrics

interface PerformanceMetrics {
  renderCount: number;
  totalRenderTime: number;
  averageRenderTime: number;
  longestRenderTime: number;
  shortestRenderTime: number;
  lastRenderTime: number;
  componentName?: string;
  timestamp: number;
}

Utilities

PerformanceUtils

import { PerformanceUtils } from "speedact";

// Get metrics for a specific component
PerformanceUtils.getComponentMetrics("ComponentName");

// Get all monitored component names
PerformanceUtils.getAllComponentNames();

// Get metrics for all components
PerformanceUtils.getAllMetrics();

// Reset metrics for a specific component
PerformanceUtils.resetComponentMetrics("ComponentName");

// Reset all metrics
PerformanceUtils.resetAllMetrics();

// Generate global report
PerformanceUtils.generateGlobalReport();

// Get active components count
PerformanceUtils.getActiveComponentsCount();

// Force cleanup all data
PerformanceUtils.forceCleanup();

Performance Grading

Components are automatically graded based on average render time:

  • A: < 16ms (60fps capable)
  • B: 16-33ms (30fps capable)
  • C: 33-50ms (20fps capable)
  • D: > 50ms (poor performance)

Examples

Basic Monitoring

import { PerformanceMonitor } from "speedact";

function App() {
  return (
    <PerformanceMonitor componentName="App" logToConsole={true}>
      <YourComponent />
    </PerformanceMonitor>
  );
}

Monitoring with Callback

import { PerformanceMonitor, PerformanceMetrics } from "speedact";

function App() {
  const handleMetricsUpdate = (metrics: PerformanceMetrics) => {
    if (metrics.lastRenderTime > 16) {
      console.warn(`Slow render detected: ${metrics.lastRenderTime}ms`);
    }
  };

  return (
    <PerformanceMonitor
      componentName="App"
      onMetricsUpdate={handleMetricsUpdate}
      threshold={16}
    >
      <YourComponent />
    </PerformanceMonitor>
  );
}

Conditional Monitoring

import { PerformanceMonitor } from "speedact";

function App() {
  const isDevelopment = process.env.NODE_ENV === "development";

  return (
    <PerformanceMonitor
      componentName="App"
      enabled={isDevelopment}
      logToConsole={isDevelopment}
    >
      <YourComponent />
    </PerformanceMonitor>
  );
}

Advanced Usage with Reports

import { PerformanceMonitor, PerformanceUtils } from "speedact";

function App() {
  const generateReport = () => {
    // Get metrics for specific component
    const metrics = PerformanceUtils.getComponentMetrics("App");
    console.log("App metrics:", metrics);

    // Generate and display global report
    const report = PerformanceUtils.generateGlobalReport();
    console.log(report);
  };

  return (
    <div>
      <button onClick={generateReport}>Generate Report</button>
      <PerformanceMonitor componentName="App" threshold={16}>
        <YourComponent />
      </PerformanceMonitor>
    </div>
  );
}

How It Works

SpeedAct uses React's Profiler API to accurately measure component render times. The library:

  1. Measures each render using performance.now()
  2. Stores metrics in an efficient circular buffer
  3. Calculates statistics automatically (average, max, min)
  4. Provides analysis and performance grading

Library Performance

  • 📦 Small: ~3.5KB gzipped
  • Fast: Minimal performance overhead
  • 🔄 Efficient: Circular buffer for memory management
  • 🛡️ Safe: Robust error handling
  • 🧹 Clean: Automatic cleanup of unused components

Features

  • Simple API: Only wrapper component approach
  • TypeScript: Full TypeScript support with complete type definitions
  • Performance grading: Automatic A-D grading system
  • Console logging: Optional automatic logging with emoji indicators
  • Memory efficient: Circular buffer prevents memory leaks
  • Flexible thresholds: Configurable performance thresholds
  • Detailed metrics: Comprehensive render statistics
  • Production ready: Minimal overhead, can be safely used in production

Browser Compatibility

  • React >= 16.8.0
  • TypeScript >= 4.0.0
  • Modern browsers with Performance API support
  • Gracefully degrades in older browsers

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Repository

https://github.com/renatokhael/speedact