UNPKG

ctrlshiftleft

Version:

AI-powered toolkit for embedding QA and security testing into development workflows

128 lines (127 loc) 3.94 kB
/** * Performance Tracker * * Utility for tracking performance metrics across the ctrl.shift.left toolkit. * Collects timing information for test generation, execution, and analysis operations. */ /** * Performance data structure for a single operation */ export interface PerformanceEntry { id: string; type: 'generation' | 'execution' | 'analysis' | 'other'; target: string; startTime: number; endTime: number; duration: number; metadata?: { success: boolean; error?: string; complexity?: number; loc?: number; generatedLoc?: number; assertions?: number; testCount?: number; [key: string]: any; }; system?: { cpuUsage?: NodeJS.CpuUsage; memoryUsage?: NodeJS.MemoryUsage; platform: string; arch: string; nodeVersion: string; }; } /** * Performance report structure */ export interface PerformanceReport { metadata: { timestamp: number; project: string; label?: string; version: string; }; entries: PerformanceEntry[]; summary: { totalDuration: number; averageDuration: number; byType: { [type: string]: { count: number; totalDuration: number; averageDuration: number; }; }; successRate: number; totalOperations: number; }; } export declare class PerformanceTracker { private entries; private activeTimers; private projectName; private version; private outputDir; private enabled; constructor(options?: { projectName?: string; version?: string; outputDir?: string; enabled?: boolean; }); /** * Start tracking an operation * @param type Operation type * @param target Component or file being processed * @param id Optional custom identifier (defaults to auto-generated) * @returns Timer ID for stopping the timer later */ startTimer(type: 'generation' | 'execution' | 'analysis' | 'other', target: string, id?: string): string; /** * Stop tracking an operation and record the performance data * @param timerId Timer ID from startTimer * @param metadata Additional data about the operation * @returns Duration in milliseconds or -1 if timer not found */ stopTimer(timerId: string, metadata?: PerformanceEntry['metadata']): number; /** * Record a completed operation without using timers * @param type Operation type * @param target Component or file being processed * @param duration Duration in milliseconds * @param metadata Additional data about the operation */ recordOperation(type: 'generation' | 'execution' | 'analysis' | 'other', target: string, duration: number, metadata?: PerformanceEntry['metadata']): void; /** * Get performance data for all recorded operations */ getEntries(): PerformanceEntry[]; /** * Generate a comprehensive performance report * @param label Optional label for the report */ generateReport(label?: string): PerformanceReport; /** * Save the performance report to a file * @param format Output format (json, markdown) * @param label Optional label for the report file * @returns Path to the saved report file */ saveReport(format?: 'json' | 'markdown', label?: string): string; /** * Generate a markdown representation of the performance report * @param report Performance report object * @returns Markdown string */ private generateMarkdownReport; /** * Reset the performance tracker, clearing all entries */ reset(): void; /** * Enable or disable the performance tracker */ setEnabled(enabled: boolean): void; } export declare const performanceTracker: PerformanceTracker;