UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

147 lines 4.05 kB
/** * Enhanced performance metrics collection for logging * Provides comprehensive monitoring and analysis capabilities */ import type { PerformanceMetrics } from './types.js'; /** * Start a performance measurement */ export declare function startMetrics(): PerformanceMetrics; /** * End a performance measurement and calculate duration */ export declare function endMetrics(metrics: PerformanceMetrics): PerformanceMetrics & { duration: number; }; /** * Calculate memory usage delta */ export declare function calculateMemoryDelta(initial: NodeJS.MemoryUsage, final: NodeJS.MemoryUsage): Record<string, number>; /** * Format memory usage for logging */ export declare function formatMemoryUsage(memory: NodeJS.MemoryUsage): Record<string, string>; /** * Format bytes to human readable string */ export declare function formatBytes(bytes: number): string; /** * Performance tracking decorator with structured logging integration */ export declare function trackPerformance<T extends (...args: unknown[]) => unknown>(fn: T, name: string, options?: { logLevel?: 'debug' | 'info' | 'warn' | 'error'; trackMemory?: boolean; trackCpu?: boolean; trackArgs?: boolean; thresholds?: { duration?: number; memory?: number; cpu?: number; }; }): T; /** * Enhanced function execution time measurement with structured logging */ export declare function measureTime<T>(fn: () => Promise<T>, label?: string, options?: { logPerformance?: boolean; trackMemory?: boolean; trackCpu?: boolean; thresholds?: { duration?: number; memory?: number; }; }): Promise<{ result: T; duration: number; memoryDelta?: Record<string, number>; cpuUsage?: number; }>; /** * Enhanced memory threshold checking with structured logging */ export declare function checkMemoryThresholds(memory: NodeJS.MemoryUsage, options?: { heapUsagePercentThreshold?: number; heapUsageAbsoluteThreshold?: number; logLevel?: 'warn' | 'error'; correlationId?: string; }): { isHealthy: boolean; warnings: string[]; metrics: { heapUsedMB: number; heapTotalMB: number; heapUsagePercent: number; externalMB: number; rssMB: number; }; }; /** * System performance snapshot */ export interface SystemPerformanceSnapshot { timestamp: string; memory: NodeJS.MemoryUsage; memoryFormatted: Record<string, string>; cpu: NodeJS.CpuUsage; uptime: number; uptimeFormatted: string; loadAverage: number[]; platform: string; arch: string; nodeVersion: string; pid: number; correlationId: string; } /** * Take a comprehensive system performance snapshot */ export declare function takePerformanceSnapshot(options?: { correlationId?: string; includeCpu?: boolean; }): SystemPerformanceSnapshot; /** * Performance monitor class for ongoing tracking (used internally) */ declare class PerformanceMonitor { private measurements; private readonly maxMeasurements; constructor(maxMeasurements?: number); /** * Start measuring an operation */ start(operation: string): string; /** * End measuring an operation */ end(operation: string, id: string): (PerformanceMetrics & { duration: number; }) | null; /** * Get statistics for an operation */ getStats(operation: string): { count: number; avgDuration: number; minDuration: number; maxDuration: number; totalDuration: number; } | null; /** * Get all operation statistics */ getAllStats(): Record<string, ReturnType<typeof this.getStats>>; /** * Clear all measurements */ clear(): void; /** * Clear measurements for a specific operation */ clearOperation(operation: string): void; } /** * Global performance monitor instance */ export declare const globalPerformanceMonitor: PerformanceMonitor; export {}; //# sourceMappingURL=performance.d.ts.map