kruonis
Version:
A tool to perform benchmarks on TS
83 lines (82 loc) • 2.43 kB
TypeScript
import { BenchmarkProperties } from './BenchmarkProperties';
import { Test } from './Test';
import { Stats } from './Stats/Stats';
/**
* The main class.
* A Benchmark consists of a group of tests that are run and compared regarding the time performances.
*/
export declare class Benchmark {
/**
* This Benchmark properties
*/
private properties;
/**
* The tests added by the user, to be run
*/
private tests;
/**
* The results obtained in the previous run of this benchmark.
* Consists of a list of pairs test name - test stats
*/
private results;
/**
* Function to run on the beginning of this benchmark
*/
private onBegin;
/**
* Function to run on the end of the benchmark (on the end of all tests)
*/
private onTestBegin;
/**
* Function to run on the end of the benchmark (on the end of all tests)
*/
private onTestEnd;
/**
* Function to run on the end of the benchmark (on the end of all tests)
*/
private onEnd;
/**
* Benchmark constructor
*
* @param properties This Benchmark properties used to create a properties object
*/
constructor(properties?: object);
/**
* Get the @BenchmarkProperties used in this Benchmark, as an object
*/
getProperties(): BenchmarkProperties;
/**
* Get the tests that perform on this Benchmark
*/
getTests(): Array<Test>;
/**
* Get the results previously obtained on this Benchmark
* @return list of pairs test name - test stats
*/
getResults(): Array<[string, Stats]>;
/**
* Add a new test to this Benchmark
*
* @param testName the test name
* @param fn The function to run on this test
* @return the created @Test
*/
add(test: Test): Benchmark;
/**
* Add an event to this Benchmark. Possibilities:
* - 'onBegin'
* - 'onTestBegin'
* - 'onTestEnd'
* - '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: any): Benchmark;
/**
* Run this Benchmark list of @Test
*
* @return results obtained as a list of pairs test name - test stats
*/
run(): Array<[string, Stats]>;
}