@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
156 lines (155 loc) • 4.2 kB
TypeScript
import { EventEmitter } from 'events';
export interface BenchmarkConfig {
suites: BenchmarkSuite[];
iterations?: number;
warmupRuns?: number;
cooldownTime?: number;
compareWithBaseline?: boolean;
generateReport?: boolean;
failOnRegression?: boolean;
regressionThreshold?: number;
outputPath?: string;
includeSystemInfo?: boolean;
includeMemoryProfile?: boolean;
includeCpuProfile?: boolean;
}
export interface BenchmarkSuite {
name: string;
description?: string;
benchmarks: Benchmark[];
setup?: () => Promise<void>;
teardown?: () => Promise<void>;
timeout?: number;
tags?: string[];
}
export interface Benchmark {
name: string;
fn: () => Promise<void> | void;
options?: BenchmarkOptions;
baseline?: number;
tags?: string[];
}
export interface BenchmarkOptions {
iterations?: number;
warmupRuns?: number;
timeout?: number;
minSamples?: number;
maxTime?: number;
async?: boolean;
}
export interface BenchmarkResult {
suite: string;
benchmark: string;
metrics: PerformanceMetrics;
samples: number[];
regression?: RegressionInfo;
timestamp: Date;
systemInfo?: SystemInfo;
memoryProfile?: MemoryProfile;
cpuProfile?: CpuProfile;
}
export interface PerformanceMetrics {
mean: number;
median: number;
min: number;
max: number;
stdDev: number;
marginOfError: number;
relativeMarginOfError: number;
samples: number;
ops: number;
}
export interface RegressionInfo {
detected: boolean;
baseline: number;
current: number;
difference: number;
percentage: number;
threshold: number;
}
export interface SystemInfo {
platform: string;
arch: string;
cpus: number;
cpuModel: string;
totalMemory: number;
nodeVersion: string;
v8Version: string;
}
export interface MemoryProfile {
heapUsedBefore: number;
heapUsedAfter: number;
heapDelta: number;
external: number;
arrayBuffers: number;
gcRuns: number;
}
export interface CpuProfile {
userTime: number;
systemTime: number;
totalTime: number;
cpuUsage: number;
}
export interface BenchmarkReport {
summary: BenchmarkSummary;
results: BenchmarkResult[];
comparisons?: BenchmarkComparison[];
systemInfo: SystemInfo;
timestamp: Date;
duration: number;
}
export interface BenchmarkSummary {
totalBenchmarks: number;
totalSuites: number;
totalSamples: number;
totalDuration: number;
regressions: number;
improvements: number;
}
export interface BenchmarkComparison {
suite: string;
benchmark: string;
baseline: PerformanceMetrics;
current: PerformanceMetrics;
change: {
absolute: number;
percentage: number;
significant: boolean;
};
}
export interface BaselineData {
version: string;
timestamp: Date;
results: Map<string, BenchmarkResult>;
}
export declare class PerformanceBenchmark extends EventEmitter {
private config;
private results;
private baseline;
constructor(config: BenchmarkConfig);
run(): Promise<BenchmarkReport>;
private runSuite;
private runBenchmark;
private executeBenchmark;
private calculateMetrics;
private checkRegression;
private collectSystemInfo;
private getMinimalSystemInfo;
private createMemoryProfile;
private createCpuProfile;
private loadBaseline;
private saveBaseline;
private generateReport;
private generateComparisons;
private saveReport;
private formatReport;
private checkRegressions;
private getVersion;
private wait;
addSuite(suite: BenchmarkSuite): void;
getResults(): BenchmarkResult[];
compareResults(a: BenchmarkResult, b: BenchmarkResult): number;
}
export declare function createBenchmark(name: string, fn: () => Promise<void> | void, options?: BenchmarkOptions): Benchmark;
export declare function createSuite(name: string, benchmarks: Benchmark[], options?: Partial<BenchmarkSuite>): BenchmarkSuite;
export declare function runBenchmarks(suites: BenchmarkSuite[], config?: Partial<BenchmarkConfig>): Promise<BenchmarkReport>;