UNPKG

tradingview-screener-ts

Version:

TypeScript port of TradingView Screener with 100% Python parity - Based on the original Python library by shner-elmo (https://github.com/shner-elmo/TradingView-Screener)

151 lines 3.59 kB
/** * Performance monitoring and optimization utilities * * This module provides advanced performance monitoring, caching, and optimization * features to achieve world-class performance standards. */ export interface PerformanceMetrics { queryTime: number; networkTime: number; parseTime: number; totalTime: number; cacheHit: boolean; dataSize: number; requestCount: number; } export interface CacheEntry<T = any> { data: T; timestamp: number; ttl: number; hits: number; } /** * Advanced performance monitor with caching and metrics */ export declare class PerformanceMonitor { private cache; private metrics; private readonly defaultTTL; /** * Execute a function with performance monitoring */ monitor<T>(key: string, fn: () => Promise<T>, options?: { ttl?: number; enableCache?: boolean; }): Promise<{ data: T; metrics: PerformanceMetrics; }>; /** * Get data from cache if valid */ private getFromCache; /** * Set data in cache */ private setCache; /** * Get performance statistics */ getStats(): { averageQueryTime: number; averageNetworkTime: number; averageTotalTime: number; cacheHitRate: number; totalRequests: number; averageDataSize: number; }; /** * Clear cache and metrics */ clear(): void; /** * Get cache statistics */ getCacheStats(): { size: number; hitRate: number; totalHits: number; entries: Array<{ key: string; hits: number; age: number; }>; }; } /** * Global performance monitor instance */ export declare const performanceMonitor: PerformanceMonitor; /** * Performance decorator for methods */ export declare function monitored(key?: string): (target: any, propertyName: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Request rate limiter */ export declare class RateLimiter { private requests; private readonly maxRequests; private readonly timeWindow; constructor(maxRequests?: number, timeWindowMs?: number); /** * Check if request is allowed */ isAllowed(): boolean; /** * Wait until next request is allowed */ waitForNext(): Promise<void>; /** * Get current rate limit status */ getStatus(): { remaining: number; resetTime: number; isLimited: boolean; }; } /** * Global rate limiter instance */ export declare const rateLimiter: RateLimiter; /** * Memory usage monitor */ export declare class MemoryMonitor { /** * Get current memory usage */ static getUsage(): { used: number; total: number; percentage: number; heapUsed?: number; heapTotal?: number; }; /** * Check if memory usage is high */ static isHighUsage(threshold?: number): boolean; } /** * Bundle size analyzer */ export declare const bundleInfo: { readonly version: "1.0.0"; readonly estimatedSize: { readonly minified: "~45KB"; readonly gzipped: "~12KB"; readonly brotli: "~10KB"; }; readonly dependencies: { readonly runtime: readonly ["axios"]; readonly development: readonly ["typescript", "jest", "eslint", "prettier"]; }; readonly treeShaking: true; readonly esModules: true; readonly commonjs: true; readonly umd: true; }; //# sourceMappingURL=performance.d.ts.map