react-chrono
Version:
A Modern Timeline component for React
71 lines (70 loc) • 2.1 kB
TypeScript
import React from 'react';
/**
* Performance monitoring utilities for React Chrono
* Helps track component render times and identify bottlenecks
*/
interface PerformanceEntry {
componentName: string;
renderTime: number;
timestamp: number;
props?: Record<string, any>;
}
declare class PerformanceMonitor {
private static instance;
private entries;
private readonly renderTimes;
private isEnabled;
static getInstance(): PerformanceMonitor;
/**
* Start timing a component render
*/
startTiming(componentName: string): () => void;
/**
* Log render time for a component
*/
private logRenderTime;
/**
* Get performance statistics for a component
*/
getStats(componentName: string): {
averageRenderTime: number;
maxRenderTime: number;
minRenderTime: number;
totalRenders: number;
} | null;
/**
* Get all performance entries
*/
getAllEntries(): PerformanceEntry[];
/**
* Clear all performance data
*/
clear(): void;
/**
* Generate performance report
*/
generateReport(): string;
/**
* Enable/disable performance monitoring
*/
setEnabled(enabled: boolean): void;
}
export declare const performanceMonitor: PerformanceMonitor;
/**
* React hook for performance monitoring
* Use this hook to time component renders
*/
export declare const usePerformanceMonitor: (componentName: string) => () => void;
/**
* Higher-order component for performance monitoring
*/
export declare function withPerformanceMonitoring<P extends Record<string, any>>(WrappedComponent: React.ComponentType<P>, componentName?: string): React.FC<P>;
/**
* Utility to measure async operations
*/
export declare const measureAsync: <T>(operation: () => Promise<T>, operationName: string) => Promise<T>;
/**
* Debounce utility with performance monitoring
*/
export declare const createPerformantDebounce: <T extends (...args: any[]) => any>(func: T, delay: number, operationName: string) => ((...args: Parameters<T>) => void);
export {};