@ai-capabilities-suite/mcp-debugger-core
Version:
Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.
119 lines (118 loc) • 3.13 kB
TypeScript
import { InspectorClient } from "./inspector-client";
/**
* Performance event types
*/
export declare enum PerformanceEventType {
FUNCTION_CALL = "FunctionCall",
SCRIPT_EVALUATION = "ScriptEvaluation",
GARBAGE_COLLECTION = "GarbageCollection",
COMPILE_SCRIPT = "CompileScript",
PARSE_SCRIPT = "ParseScript",
OTHER = "Other"
}
/**
* Performance event recorded in the timeline
*/
export interface PerformanceEvent {
type: PerformanceEventType;
name: string;
startTime: number;
endTime: number;
duration: number;
details?: Record<string, any>;
}
/**
* Function execution timing
*/
export interface FunctionTiming {
functionName: string;
file: string;
line: number;
callCount: number;
totalTime: number;
averageTime: number;
minTime: number;
maxTime: number;
}
/**
* Performance report with timeline analysis
*/
export interface PerformanceReport {
totalDuration: number;
eventCount: number;
events: PerformanceEvent[];
slowOperations: PerformanceEvent[];
functionTimings: FunctionTiming[];
gcTime: number;
gcCount: number;
}
/**
* Performance Timeline for recording and analyzing performance events
* Tracks function execution times and identifies slow operations
*/
export declare class PerformanceTimeline {
private inspector;
private recording;
private events;
private startTime;
private functionTimings;
constructor(inspector: InspectorClient);
/**
* Start recording performance events
*/
startRecording(): Promise<void>;
/**
* Stop recording performance events
* @returns Performance report
*/
stopRecording(): Promise<PerformanceReport>;
/**
* Handle console API calls (for console.time/timeEnd)
*/
private handleConsoleAPI;
/**
* Record a performance event
* @param event The event to record
*/
recordEvent(event: PerformanceEvent): void;
/**
* Record a function call timing
* @param functionName Name of the function
* @param file File path
* @param line Line number
* @param duration Duration in microseconds
*/
recordFunctionCall(functionName: string, file: string, line: number, duration: number): void;
/**
* Record a garbage collection event
* @param duration Duration in microseconds
*/
recordGarbageCollection(duration: number): void;
/**
* Generate a performance report from recorded events
* @returns Performance report
*/
generateReport(): PerformanceReport;
/**
* Format performance report as a human-readable string
* @param report The performance report to format
* @returns Formatted string
*/
formatReport(report: PerformanceReport): string;
/**
* Check if recording is active
*/
isRecording(): boolean;
/**
* Get all recorded events
*/
getEvents(): PerformanceEvent[];
/**
* Clear all recorded events
*/
clearEvents(): void;
/**
* Get function timings
*/
getFunctionTimings(): FunctionTiming[];
}