@gebrai/gebrai
Version:
Model Context Protocol server for GeoGebra mathematical visualization
76 lines • 2.13 kB
TypeScript
/**
* Performance Monitoring and Optimization System
* GEB-9: Performance Optimization: Response Time and Resource Management
*/
export interface PerformanceMetrics {
operationName: string;
startTime: number;
endTime: number;
duration: number;
success: boolean;
errorMessage?: string;
memoryUsage?: NodeJS.MemoryUsage;
metadata?: Record<string, any>;
}
export interface PerformanceThresholds {
[operationName: string]: {
warning: number;
critical: number;
};
}
export declare class PerformanceMonitor {
private static instance;
private metrics;
private thresholds;
private maxMetrics;
private defaultThresholds;
private constructor();
static getInstance(): PerformanceMonitor;
/**
* Start timing an operation
*/
startTiming(operationName: string, metadata?: Record<string, any>): (success?: boolean, errorMessage?: string) => PerformanceMetrics;
/**
* Measure and record an async operation
*/
measureOperation<T>(operationName: string, operation: () => Promise<T>, metadata?: Record<string, any>): Promise<T>;
/**
* Add a metric to the collection
*/
private addMetric;
/**
* Check if metric exceeds thresholds and log warnings
*/
private checkThresholds;
/**
* Get performance statistics for an operation
*/
getStats(operationName?: string): {
count: number;
averageDuration: number;
medianDuration: number;
minDuration: number;
maxDuration: number;
successRate: number;
p95Duration: number;
p99Duration: number;
};
/**
* Get all operation names with metrics
*/
getOperationNames(): string[];
/**
* Clear all metrics
*/
clearMetrics(): void;
/**
* Export metrics for analysis
*/
exportMetrics(): PerformanceMetrics[];
/**
* Set custom thresholds
*/
setThresholds(thresholds: Partial<PerformanceThresholds>): void;
}
export declare const performanceMonitor: PerformanceMonitor;
//# sourceMappingURL=index.d.ts.map