UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

200 lines 5.65 kB
/** * @fileoverview OrdoJS Performance Benchmarker - Comprehensive performance measurement and optimization */ import { OptimizationError } from '../types/index.js'; /** * Performance metrics for different operations */ export interface PerformanceMetrics { /** Compilation time in milliseconds */ compilationTime: number; /** Lexical analysis time in milliseconds */ lexingTime: number; /** Parsing time in milliseconds */ parsingTime: number; /** Code generation time in milliseconds */ codeGenerationTime: number; /** Optimization time in milliseconds */ optimizationTime: number; /** Bundle size in bytes */ bundleSize: number; /** Gzipped bundle size in bytes */ gzippedSize: number; /** Brotli compressed bundle size in bytes */ brotliSize: number; /** Number of AST nodes */ astNodeCount: number; /** Number of tokens generated */ tokenCount: number; /** Memory usage in bytes */ memoryUsage: number; /** Hydration time in milliseconds */ hydrationTime?: number; /** Runtime performance metrics */ runtimeMetrics?: RuntimeMetrics; } /** * Runtime performance metrics */ export interface RuntimeMetrics { /** Time to first meaningful paint in milliseconds */ timeToFirstPaint: number; /** Time to interactive in milliseconds */ timeToInteractive: number; /** Memory usage during runtime in bytes */ runtimeMemoryUsage: number; /** Number of DOM operations */ domOperations: number; /** Reactive update time in milliseconds */ reactiveUpdateTime: number; } /** * Benchmark configuration */ export interface BenchmarkConfig { /** Number of iterations for averaging */ iterations: number; /** Whether to include runtime benchmarks */ includeRuntime: boolean; /** Whether to measure memory usage */ measureMemory: boolean; /** Whether to generate compression metrics */ includeCompression: boolean; /** Target bundle size for optimization */ targetBundleSize?: number; /** Performance thresholds */ thresholds: PerformanceThresholds; } /** * Performance thresholds for validation */ export interface PerformanceThresholds { /** Maximum compilation time in milliseconds */ maxCompilationTime: number; /** Maximum bundle size in bytes */ maxBundleSize: number; /** Maximum hydration time in milliseconds */ maxHydrationTime: number; /** Maximum time to first paint in milliseconds */ maxTimeToFirstPaint: number; /** Maximum time to interactive in milliseconds */ maxTimeToInteractive: number; } /** * Benchmark result */ export interface BenchmarkResult { /** Component name */ componentName: string; /** Average metrics across iterations */ averageMetrics: PerformanceMetrics; /** All individual measurements */ measurements: PerformanceMetrics[]; /** Performance validation results */ validation: PerformanceValidation; /** Optimization suggestions */ suggestions: string[]; /** Comparison with baseline */ comparison?: PerformanceComparison; } /** * Performance validation results */ export interface PerformanceValidation { /** Whether all thresholds are met */ passed: boolean; /** Failed threshold checks */ failures: string[]; /** Performance score (0-100) */ score: number; } /** * Performance comparison with baseline */ export interface PerformanceComparison { /** Baseline metrics */ baseline: PerformanceMetrics; /** Current metrics */ current: PerformanceMetrics; /** Percentage improvement/degradation */ improvement: { compilationTime: number; bundleSize: number; hydrationTime: number; overall: number; }; } /** * Comprehensive performance benchmarker for OrdoJS components */ export declare class PerformanceBenchmarker { private config; private baselineMetrics; private errors; constructor(config?: Partial<BenchmarkConfig>); /** * Benchmark a component's performance */ benchmarkComponent(source: string, componentName: string, baselineName?: string): Promise<BenchmarkResult>; /** * Set baseline metrics for comparison */ setBaseline(name: string, metrics: PerformanceMetrics): void; /** * Get baseline metrics */ getBaseline(name: string): PerformanceMetrics | undefined; /** * Get benchmark errors */ getErrors(): OptimizationError[]; /** * Measure performance of a single compilation */ private measurePerformance; /** * Calculate average metrics across measurements */ private calculateAverageMetrics; /** * Validate performance against thresholds */ private validatePerformance; /** * Generate optimization suggestions */ private generateSuggestions; /** * Compare with baseline metrics */ private compareWithBaseline; /** * Calculate bundle size */ private calculateBundleSize; /** * Calculate gzipped size (simplified) */ private calculateGzippedSize; /** * Calculate Brotli size (simplified) */ private calculateBrotliSize; /** * Count AST nodes */ private countASTNodes; /** * Get memory usage */ private getMemoryUsage; /** * Measure runtime performance */ private measureRuntimePerformance; /** * Generate performance report */ generateReport(result: BenchmarkResult): string; } //# sourceMappingURL=performance-benchmarker.d.ts.map