UNPKG

unpak.js

Version:

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

197 lines 5.97 kB
import { EventEmitter } from 'events'; /** * Asset parsing benchmark system * Addresses roadmap item: "Performance Optimization - Asset parsing benchmarks and profiling" * * This system provides comprehensive performance monitoring for: * - Asset parsing operations across different types * - Archive reading and extraction performance * - Memory usage patterns during processing * - Comparative analysis between different approaches */ export declare class AssetParsingBenchmark extends EventEmitter { private readonly benchmarks; private readonly activeBenchmarks; private readonly systemMetrics; constructor(); /** * Start a new benchmark session */ startBenchmark(name: string, category?: BenchmarkCategory, options?: BenchmarkOptions): BenchmarkSession; /** * End a benchmark session and record results */ endBenchmark(name: string): BenchmarkResult; /** * Benchmark asset parsing performance */ benchmarkAssetParsing<T>(assetType: string, assets: Array<{ name: string; data: Buffer; }>, parser: (data: Buffer) => Promise<T>, options?: AssetParsingBenchmarkOptions): Promise<AssetParsingBenchmarkResult>; /** * Benchmark archive reading performance */ benchmarkArchiveReading(archivePath: string, filePatterns: string[], archiveReader: any, options?: ArchiveBenchmarkOptions): Promise<ArchiveBenchmarkResult>; /** * Run comparative benchmark between different approaches */ runComparativeBenchmark<T>(name: string, testData: any[], approaches: Array<{ name: string; implementation: (data: any) => Promise<T>; }>, options?: ComparativeBenchmarkOptions): Promise<ComparativeBenchmarkResult>; /** * Get benchmark results by name */ getBenchmarkResults(name: string): BenchmarkResult[]; /** * Get all benchmark results */ getAllBenchmarkResults(): Map<string, BenchmarkResult[]>; /** * Generate benchmark report */ generateReport(category?: BenchmarkCategory): BenchmarkReport; /** * Generate performance recommendations based on benchmark data */ private generateRecommendations; } /** * Individual benchmark session */ declare class BenchmarkSession { readonly name: string; readonly category: BenchmarkCategory; readonly startTime: number; readonly options: BenchmarkOptions; private operationCount; private errorCount; private memoryPeak; private startMemory; constructor(name: string, category: BenchmarkCategory, options: BenchmarkOptions); recordOperation(type: string): void; recordError(): void; updateMemoryPeak(currentMemory?: number): void; end(): BenchmarkResult; } export type BenchmarkCategory = 'general' | 'asset-parsing' | 'archive-reading' | 'comparative' | 'memory' | 'performance'; export interface BenchmarkOptions { description?: string; tags?: string[]; collectSystemMetrics?: boolean; } export interface BenchmarkResult { name: string; category: BenchmarkCategory; startTime: number; endTime: number; duration: number; operationCount: number; errorCount: number; memoryPeak: number; memoryDelta: number; options: BenchmarkOptions; } export interface AssetParsingBenchmarkOptions extends BenchmarkOptions { warmupRuns?: number; includeDetailedResults?: boolean; } export interface AssetParsingBenchmarkResult extends BenchmarkResult { assetType: string; assetCount: number; successCount: number; errorCount: number; successRate: number; averageParseTime: number; minParseTime: number; maxParseTime: number; totalMemoryUsed: number; averageMemoryPerAsset: number; throughput: number; detailedResults?: Array<{ name: string; duration: number; success: boolean; memoryDelta: number; }>; } export interface ArchiveBenchmarkOptions extends BenchmarkOptions { maxFiles?: number; includeDetailedResults?: boolean; } export interface ArchiveOperationResult { operation: string; duration: number; fileCount: number; bytes: number; success: boolean; fileName?: string; error?: string; } export interface ArchiveBenchmarkResult extends BenchmarkResult { archivePath: string; totalFiles: number; filesRead: number; successfulReads: number; totalBytes: number; averageReadTime: number; throughputMBps: number; operationResults?: ArchiveOperationResult[]; } export interface ComparativeBenchmarkOptions extends BenchmarkOptions { iterations?: number; } export interface ApproachResult { name: string; totalTime: number; averageTime: number; successCount: number; errorCount: number; successRate: number; memoryPeak: number; throughput: number; relativePerformance?: number; performanceRatio?: number; } export interface ComparativeBenchmarkResult { name: string; testDataSize: number; approaches: ApproachResult[]; bestApproach: string; worstApproach: string; } export interface SystemMetrics { memory: { heapUsed: number; heapTotal: number; external: number; rss: number; }; cpu: { user: number; system: number; }; timestamp: number; } export interface BenchmarkReport { totalBenchmarks: number; categories: BenchmarkCategory[]; summary: { totalDuration: number; averageDuration: number; totalOperations: number; averageMemoryPeak: number; }; recommendations: string[]; } /** * Factory function to create a new benchmark instance */ export declare function createBenchmark(): AssetParsingBenchmark; /** * Global benchmark instance for convenience */ export declare const globalBenchmark: AssetParsingBenchmark; export {}; //# sourceMappingURL=AssetParsingBenchmark.d.ts.map