@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and
106 lines (105 loc) • 3.02 kB
TypeScript
/**
* Performance measurement and memory management utilities
* Part of Sub-phase 3.3.1-3.3.2 optimization efforts
*/
export interface PerformanceMetrics {
startTime: number;
endTime?: number;
duration?: number;
memoryStart: NodeJS.MemoryUsage;
memoryEnd?: NodeJS.MemoryUsage;
memoryDelta?: {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
};
}
/**
* Performance measurement utility for tracking operations
*/
export declare class PerformanceTracker {
private metrics;
/**
* Start tracking performance for an operation
*/
start(operationName: string): void;
/**
* End tracking and calculate metrics
*/
end(operationName: string): PerformanceMetrics | null;
/**
* Get metrics for an operation
*/
getMetrics(operationName: string): PerformanceMetrics | null;
/**
* Clear all metrics
*/
clear(): void;
/**
* Format metrics for display
*/
formatMetrics(operationName: string): string;
}
/**
* Global performance tracker instance
*/
export declare const globalTracker: PerformanceTracker;
/**
* Memory management utilities
*/
export declare class MemoryManager {
/**
* Force garbage collection if available
*/
static forceGC(): boolean;
/**
* Get current memory usage in MB
*/
static getMemoryUsageMB(): {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
};
/**
* Monitor memory usage and warn if it exceeds threshold
*/
static monitorMemory(threshold?: number): boolean;
/**
* Clean up and optimize memory usage.
* Attempts to force garbage collection if available.
*
* @returns {object|null} Memory usage statistics if cleanup was performed, or null if not possible.
* - If manual garbage collection is not available (i.e., Node.js not run with --expose-gc),
* no cleanup is performed and null is returned.
* - Clearing the require cache is not attempted due to potential side effects.
*/
static cleanup(): {
beforeMB: number;
afterMB: number;
freedMB: number;
} | null;
}
/**
* Decorator for tracking performance of async functions
*/
export declare function trackPerformance(operationName: string): <T extends (...args: unknown[]) => Promise<unknown>>(target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
/**
* Performance monitoring for CLI operations
*/
export declare class CLIPerformanceMonitor {
private static instance;
private enabled;
static getInstance(): CLIPerformanceMonitor;
enable(): void;
disable(): void;
/**
* Monitor a CLI operation
*/
monitorOperation<T>(operationName: string, operation: () => Promise<T>): Promise<T>;
}
/**
* Export singleton monitor for easy access
*/
export declare const cliMonitor: CLIPerformanceMonitor;