agentjs-core
Version:
A comprehensive agent-based modeling framework with built-in p5.js visualization
118 lines • 2.94 kB
TypeScript
/**
* PerformanceBenchmark - Comprehensive performance testing suite
*/
import { EventEmitter } from 'eventemitter3';
/** Benchmark configuration */
export interface BenchmarkConfig {
agentCounts: number[];
iterations: number;
warmupIterations: number;
environmentSize: {
width: number;
height: number;
};
enableNetworks: boolean;
enableBehaviors: boolean;
enableInteractions: boolean;
targetFPS: number;
}
/** Benchmark result for a single test */
export interface BenchmarkResult {
agentCount: number;
avgStepTime: number;
minStepTime: number;
maxStepTime: number;
medianStepTime: number;
percentile95: number;
percentile99: number;
fps: number;
memoryUsed: number;
gcTime: number;
}
/** Complete benchmark report */
export interface BenchmarkReport {
timestamp: number;
config: BenchmarkConfig;
results: BenchmarkResult[];
summary: {
maxAgentsAt60FPS: number;
maxAgentsAt30FPS: number;
scalabilityFactor: number;
memoryEfficiency: number;
};
}
/**
* PerformanceBenchmark - Tests framework performance at scale
*
* Features:
* - Automated performance testing with various agent counts
* - FPS and step time measurements
* - Memory usage profiling
* - Garbage collection impact analysis
* - Scalability testing
* - Performance regression detection
*
* Educational Context: Validates that the framework can
* handle realistic simulation sizes while maintaining
* acceptable performance for interactive use.
*/
export declare class PerformanceBenchmark extends EventEmitter {
private config;
private results;
constructor(config?: Partial<BenchmarkConfig>);
/**
* Run complete benchmark suite
*/
runBenchmark(): Promise<BenchmarkReport>;
/**
* Benchmark specific agent count
*/
private benchmarkAgentCount;
/**
* Setup simulation with specified agent count
*/
private setupSimulation;
/**
* Step simulation once
*/
private stepSimulation;
/**
* Cleanup simulation
*/
private cleanupSimulation;
/**
* Cool down between tests
*/
private coolDown;
/**
* Generate benchmark report
*/
private generateReport;
/**
* Find maximum agents that maintain target FPS
*/
private findMaxAgentsAtFPS;
/**
* Calculate scalability factor (sublinear is good)
*/
private calculateScalabilityFactor;
/**
* Calculate memory efficiency (bytes per agent)
*/
private calculateMemoryEfficiency;
/**
* Statistical helpers
*/
private average;
private median;
private percentile;
/**
* Get configuration
*/
getConfig(): BenchmarkConfig;
/**
* Get last results
*/
getLastResults(): BenchmarkResult[];
}
//# sourceMappingURL=PerformanceBenchmark.d.ts.map