ai-debug-local-mcp
Version:
🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
103 lines • 2.73 kB
JavaScript
// Startup Performance Tracker - Measures initialization performance
/**
* StartupPerformanceTracker - Tracks server startup performance
* Used to measure and validate startup time improvements
*/
export class StartupPerformanceTracker {
startTime;
phases = new Map();
currentPhase = null;
constructor() {
this.startTime = Date.now();
}
/**
* Start tracking a specific phase
*/
startPhase(name) {
// End current phase if exists
if (this.currentPhase) {
this.endPhase(this.currentPhase);
}
const phase = {
name,
startTime: Date.now()
};
this.phases.set(name, phase);
this.currentPhase = name;
}
/**
* End tracking a specific phase
*/
endPhase(name) {
const phase = this.phases.get(name);
if (!phase) {
return;
}
const endTime = Date.now();
phase.endTime = endTime;
phase.duration = endTime - phase.startTime;
if (this.currentPhase === name) {
this.currentPhase = null;
}
}
/**
* Get complete startup metrics
*/
getMetrics() {
const now = Date.now();
const totalStartupTime = now - this.startTime;
const phaseMetrics = {};
for (const [name, phase] of this.phases) {
phaseMetrics[name] = phase.duration || (now - phase.startTime);
}
return {
totalStartupTime,
phases: phaseMetrics,
startedAt: new Date(this.startTime),
completedAt: new Date(now)
};
}
/**
* Get current phase duration
*/
getCurrentPhaseDuration() {
if (!this.currentPhase) {
return 0;
}
const phase = this.phases.get(this.currentPhase);
if (!phase) {
return 0;
}
return Date.now() - phase.startTime;
}
/**
* Reset tracker
*/
reset() {
this.startTime = Date.now();
this.phases.clear();
this.currentPhase = null;
}
/**
* Mark startup complete
*/
markComplete() {
if (this.currentPhase) {
this.endPhase(this.currentPhase);
}
}
/**
* Get performance improvement percentage
*/
getImprovementPercentage(baselineTime) {
const currentTime = this.getMetrics().totalStartupTime;
return ((baselineTime - currentTime) / baselineTime) * 100;
}
/**
* Check if target startup time is met
*/
meetsTarget(targetTime) {
return this.getMetrics().totalStartupTime <= targetTime;
}
}
//# sourceMappingURL=startup-performance-tracker.js.map