UNPKG

unpak.js

Version:

Modern TypeScript library for reading Unreal Engine pak files and assets, inspired by CUE4Parse

138 lines 3.79 kB
import { EventEmitter } from 'events'; /** * Just-In-Time Compilation System for Hot Asset Paths * Phase 11 - Performance and Optimization * * This system provides: * - JIT compilation for frequently accessed asset parsing paths * - Performance hotspot detection and optimization * - Dynamic code generation for asset-specific parsers * - Runtime optimization based on usage patterns */ export interface HotPath { path: string; frequency: number; averageTime: number; totalTime: number; lastAccessed: Date; optimized: boolean; compiledCode?: Function; } export interface JITStatistics { totalHotPaths: number; optimizedPaths: number; compilationTime: number; performanceGain: number; cacheHitRate: number; } export interface OptimizationHint { assetType: string; operation: string; pattern: string; frequency: number; suggestedOptimization: string; } /** * JIT Compiler for Asset Processing */ export declare class AssetJITCompiler extends EventEmitter { private hotPaths; private compiledFunctions; private performanceThreshold; private frequencyThreshold; private maxCacheSize; private statistics; private optimizationHints; constructor(options?: { performanceThreshold?: number; frequencyThreshold?: number; maxCacheSize?: number; }); /** * Track asset processing performance */ trackAssetProcessing(assetPath: string, operation: string, executionTime: number): void; /** * Check if a path qualifies for JIT optimization */ private checkForOptimization; /** * Schedule JIT optimization for a hot path */ private scheduleOptimization; /** * Compile optimized parser for specific asset patterns */ private compileOptimizedParser; /** * Compile texture-specific optimizer */ private compileTextureOptimizer; /** * Compile mesh-specific optimizer */ private compileMeshOptimizer; /** * Compile material-specific optimizer */ private compileMaterialOptimizer; /** * Compile sound-specific optimizer */ private compileSoundOptimizer; /** * Compile animation-specific optimizer */ private compileAnimationOptimizer; /** * Compile generic optimizer */ private compileGenericOptimizer; /** * Execute optimized function if available, fallback to original */ executeOptimized(pathKey: string, originalFunction: Function, ...args: any[]): any; /** * Detect asset type from path */ private detectAssetType; /** * Track performance gain from optimization */ private trackOptimizationGain; /** * Generate optimization hints based on patterns */ generateOptimizationHints(): OptimizationHint[]; /** * Get suggested optimization for asset type and operation */ private getSuggestedOptimization; /** * Get current JIT statistics */ getStatistics(): JITStatistics; /** * Get hot paths information */ getHotPaths(): HotPath[]; /** * Clear optimization cache */ clearCache(): void; /** * Enable/disable JIT optimization */ setEnabled(enabled: boolean): void; } /** * Decorator for automatic JIT optimization tracking */ export declare function JITOptimize(assetType: string, operation: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Factory function to create JIT compiler instance */ export declare function createJITCompiler(config: { scenario: 'development' | 'production' | 'performance'; }): AssetJITCompiler; //# sourceMappingURL=JITCompiler.d.ts.map