schemantic
Version:
A fully typed, extensible TypeScript type generator for FastAPI OpenAPI schemas
98 lines • 2.91 kB
TypeScript
/**
* Advanced Performance Monitoring Plugin
*
* Implements sophisticated performance tracking, bundle size optimization,
* and intelligent monitoring for generated API clients and types.
*
* Key Features:
* - Request timing collection with statistical analysis
* - Bundle size analysis and optimization recommendations
* - Memory usage profiling and leak detection
* - Performance regression detection
* - Automated optimization suggestions
*
* Architecture:
* - Non-intrusive performance instrumentation
* - Statistical analysis with percentile calculations
* - Memory-efficient metrics storage with TTL
* - Configurable monitoring thresholds
*/
import { SchemanticPlugin } from "../types/core";
/**
* Performance metric data structure
*/
interface PerformanceMetric {
timestamp: number;
operation: string;
duration: number;
metadata: Record<string, unknown>;
}
/**
* Bundle analysis result
*/
interface BundleAnalysis {
totalSize: number;
gzippedSize?: number;
chunks: {
name: string;
size: number;
dependencies: string[];
}[];
recommendations: string[];
}
/**
* Performance statistics calculator
*/
declare class PerformanceAnalyzer {
private readonly maxSnapshots;
constructor(maxSnapshots?: number);
recordMetric(metric: PerformanceMetric): void;
getStatistics(operation: string): PerformanceStatistics | null;
private getPercentile;
private calculateStandardDeviation;
recordMemorySnapshot(): void;
analyzeBundleSize(generatedContent: string, dependencies: string[]): BundleAnalysis;
generateReport(format?: "json" | "html" | "markdown"): string;
private getAllStatistics;
/**
* Get all statistics (public method)
*/
getAllStats(): Record<string, PerformanceStatistics>;
private getMemoryAnalysis;
private generateHTMLReport;
private generateMarkdownReport;
clearMetrics(): void;
}
/**
* Performance statistics interface
*/
interface PerformanceStatistics {
count: number;
min: number;
max: number;
mean: number;
median: number;
p95: number;
p99: number;
standardDeviation: number;
}
/**
* Global performance analyzer instance
*/
declare const performanceAnalyzer: PerformanceAnalyzer;
/**
* Advanced Performance Monitoring Plugin Implementation
*/
export declare const performanceMonitoringPlugin: SchemanticPlugin;
/**
* Export performance analyzer instance for external use
*/
export { performanceAnalyzer };
/**
* Export utility functions
*/
export declare function getPerformanceMonitoringStats(): Record<string, PerformanceStatistics>;
export declare function clearPerformanceMonitoringCache(): void;
export declare function generatePerformanceReport(format?: "json" | "html" | "markdown"): string;
export default performanceMonitoringPlugin;
//# sourceMappingURL=performance-monitoring.d.ts.map