/** * @file Deep Performance Profiler * @description Enterprise-grade performance profiling with runtime analysis, * bottleneck detection, and actionable insights. Integrates with React DevTools * Profiler API and Performance Observer API. * * Features: * - Component render timing * - Long task detection * - Memory pressure monitoring * - Frame rate analysis * - Network waterfall tracking * - Custom mark/measure API */ /** * Profiler configuration */ export interface ProfilerConfig { /** Enable profiling (disable in production for zero overhead) */ enabled: boolean; /** Maximum number of entries to store */ maxEntries: number; /** Enable long task detection */ detectLongTasks: boolean; /** Long task threshold in ms */ longTaskThreshold: number; /** Enable frame rate monitoring */ monitorFrameRate: boolean; /** Frame rate sample interval in ms */ frameRateSampleInterval: number; /** Enable memory monitoring */ monitorMemory: boolean; /** Memory sample interval in ms */ memorySampleInterval: number; /** Enable automatic performance marks */ autoMark: boolean; /** Debug mode */ debug: boolean; } /** * Render timing entry */ export interface RenderTimingEntry { id: string; componentName: string; phase: 'mount' | 'update' | 'unmount'; actualDuration: number; baseDuration: number; startTime: number; commitTime: number; interactions: Set; timestamp: number; } /** * Long task entry */ export interface LongTaskEntry { id: string; name: string; duration: number; startTime: number; attribution: LongTaskAttribution[]; timestamp: number; } /** * Long task attribution */ export interface LongTaskAttribution { name: string; entryType: string; startTime: number; duration: number; containerType: string; containerSrc: string; containerId: string; containerName: string; } /** * Frame rate sample */ export interface FrameRateSample { fps: number; frameTime: number; jank: boolean; timestamp: number; } /** * Memory sample */ export interface MemorySample { usedJSHeapSize: number; totalJSHeapSize: number; jsHeapSizeLimit: number; usagePercent: number; trend: 'increasing' | 'stable' | 'decreasing'; timestamp: number; } /** * Custom performance mark */ export interface PerformanceMark { name: string; startTime: number; detail?: unknown; } /** * Custom performance measure */ export interface PerformanceMeasure { name: string; startMark: string; endMark: string; duration: number; startTime: number; detail?: unknown; } /** * Performance snapshot */ export interface PerformanceSnapshot { renders: RenderTimingEntry[]; longTasks: LongTaskEntry[]; frameRate: FrameRateSample[]; memory: MemorySample[]; marks: PerformanceMark[]; measures: PerformanceMeasure[]; summary: PerformanceSummary; timestamp: number; } /** * Performance summary */ export interface PerformanceSummary { averageRenderTime: number; maxRenderTime: number; totalRenders: number; slowRenders: number; longTaskCount: number; totalLongTaskTime: number; averageFPS: number; minFPS: number; jankFrames: number; memoryTrend: 'increasing' | 'stable' | 'decreasing' | 'unknown'; potentialMemoryLeak: boolean; } /** * Profiler event type */ export type ProfilerEventType = 'render' | 'longTask' | 'frameRate' | 'memory' | 'mark' | 'measure'; /** * Profiler event listener */ export type ProfilerEventListener = (type: ProfilerEventType, entry: unknown) => void; /** * Deep performance profiler with runtime analysis */ export declare class PerformanceProfiler { private config; private renders; private longTasks; private frameRateSamples; private memorySamples; private marks; private measures; private listeners; private longTaskObserver; private frameRateTimer; private memoryTimer; private isRunning; private idCounter; constructor(config?: Partial); /** * Start profiling */ start(): void; /** * Stop profiling */ stop(): void; /** * Record a component render (for React Profiler integration) */ recordRender(id: string, phase: 'mount' | 'update', actualDuration: number, baseDuration: number, startTime: number, commitTime: number, interactions: Set): void; /** * Create a performance mark */ mark(name: string, detail?: unknown): void; /** * Create a performance measure between two marks */ measure(name: string, startMark: string, endMark?: string): PerformanceMeasure | null; /** * Start a timed operation (returns function to end timing) */ startTiming(name: string): () => number; /** * Get current performance snapshot */ getSnapshot(): PerformanceSnapshot; /** * Clear all profiling data */ clear(): void; /** * Subscribe to profiler events */ subscribe(listener: ProfilerEventListener): () => void; /** * Export profiling data as JSON */ exportData(): string; private startLongTaskDetection; private startFrameRateMonitoring; private startMemoryMonitoring; private calculateMemoryTrend; private markNavigationTimings; private calculateSummary; private addEntry; private notifyListeners; private generateId; private log; } /** * Get or create the global profiler instance */ export declare function getPerformanceProfiler(config?: Partial): PerformanceProfiler; /** * Reset the profiler instance (for testing) */ export declare function resetPerformanceProfiler(): void; /** * Create a React Profiler onRender callback */ export declare function createProfilerCallback(profiler?: PerformanceProfiler): (id: string, phase: 'mount' | 'update', actualDuration: number, baseDuration: number, startTime: number, commitTime: number, interactions: Set) => void;