/** * Performance profiling and optimization utilities for In Memoria * Helps identify and optimize hot paths in the codebase */ export interface PerformanceMetric { name: string; startTime: number; endTime?: number; duration?: number; metadata?: Record; } export interface ProfileResult { totalDuration: number; operationCount: number; averageDuration: number; slowestOperations: PerformanceMetric[]; metrics: PerformanceMetric[]; } /** * Simple performance profiler for identifying bottlenecks */ export declare class PerformanceProfiler { private metrics; private activeOperations; /** * Start timing an operation */ startOperation(name: string, metadata?: Record): string; /** * End timing an operation */ endOperation(operationId: string): PerformanceMetric | null; /** * Time a synchronous operation */ timeSync(name: string, operation: () => T, metadata?: Record): T; /** * Time an asynchronous operation */ timeAsync(name: string, operation: () => Promise, metadata?: Record): Promise; /** * Get performance profile for a specific operation */ getProfile(operationName: string): ProfileResult | null; /** * Get all performance profiles */ getAllProfiles(): Record; /** * Get summary of all performance metrics */ getSummary(): { totalOperations: number; totalTime: number; operationTypes: number; slowestOperation: PerformanceMetric | null; fastestOperation: PerformanceMetric | null; }; /** * Clear all metrics */ clear(): void; /** * Generate performance report */ generateReport(): string; } /** * Global performance profiler instance */ export declare const globalProfiler: PerformanceProfiler; /** * Decorator for timing class methods */ export declare function timed(target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor; /** * Performance optimization utilities */ export declare class PerformanceOptimizer { /** * Debounce function calls to reduce frequency */ static debounce any>(func: T, wait: number): (...args: Parameters) => void; /** * Throttle function calls to limit frequency */ static throttle any>(func: T, limit: number): (...args: Parameters) => void; /** * Memoize function results for performance */ static memoize any>(func: T, getKey?: (...args: Parameters) => string): T; /** * Batch multiple operations together */ static createBatcher(batchProcessor: (items: T[]) => Promise, batchSize?: number, batchDelay?: number): (item: T) => Promise; } //# sourceMappingURL=performance-profiler.d.ts.map