@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
59 lines • 1.6 kB
TypeScript
/**
* Benchmark utilities for performance testing
*/
/**
* Benchmark result
*/
export interface BenchmarkResult {
/** Benchmark name */
name: string;
/** Number of iterations */
iterations: number;
/** Total time in milliseconds */
totalTime: number;
/** Average time per iteration in milliseconds */
averageTime: number;
/** Operations per second */
opsPerSecond: number;
/** Minimum time */
minTime: number;
/** Maximum time */
maxTime: number;
}
/**
* Runs a benchmark
*
* @param name - Benchmark name
* @param fn - Function to benchmark
* @param iterations - Number of iterations (default: 1000)
* @param warmup - Number of warmup iterations (default: 10)
* @returns Benchmark result
*
* @example
* ```typescript
* const result = benchmark('vector addition', () => {
* v1.add(v2);
* }, 10000);
* console.log(result.opsPerSecond);
* ```
*/
export declare function benchmark(name: string, fn: () => void, iterations?: number, warmup?: number): BenchmarkResult;
/**
* Compares multiple benchmarks
*
* @param benchmarks - Array of benchmark functions
* @param iterations - Number of iterations per benchmark
* @returns Array of benchmark results
*/
export declare function compareBenchmarks(benchmarks: Array<{
name: string;
fn: () => void;
}>, iterations?: number): BenchmarkResult[];
/**
* Formats benchmark result as string
*
* @param result - Benchmark result
* @returns Formatted string
*/
export declare function formatBenchmark(result: BenchmarkResult): string;
//# sourceMappingURL=benchmark.d.ts.map