kruonis
Version:
A tool to perform benchmarks on TS
66 lines (65 loc) • 1.84 kB
TypeScript
import { Stats } from './Stats/Stats';
/**
* A test represents a code that shall be run and afterwards compared regarding the performance
*/
export declare class Test {
readonly name: string;
private fn;
private static readonly SECONDS_TO_MILLISECONDS;
/**
* The measured times for the ran cycles, in milliseconds
*/
private cycleTimes;
/**
* The stats obtained by running this test
*/
private stats;
/**
* Function to run on the begin of the test
*/
private onBegin;
/**
* Function to run after before running each cycle
*/
private onCycleBegin;
/**
* Function to run after each cycle completes
*/
private onCycleEnd;
/**
* Function to run on the end of all test cycles
*/
private onEnd;
/**
* @param name The test name
* @param fn The function to be run
*/
constructor(name: string, fn: () => void);
/**
* Add an event to this Test. Possibilities:
* - 'onBegin'
* - 'onCycleBegin'
* - 'onCycleEnd'
* - 'onEnd'
*
* @param eventName The name of the event to be altered
* @param fn The function that will run when the event is called
*/
on(eventName: string, fn: (test: Test) => void): Test;
/**
* Gets the test baseline time (the time it takes to measure the times)
*/
private getBaselineTime;
/**
* Run this test according to the given testProperties
*
* @param testProperties the testProperties to use on this test. Similar to a @BenchmarkProperties object
*/
run(testProperties: any): void;
/**
* Get the stats obtained by running this test
*
* @return @Stats instance
*/
getStats(): Stats;
}