forked from lightsofapollo/mocha-benchmark
/
mocha_benchmark.d.ts
58 lines (58 loc) · 2.79 KB
/
mocha_benchmark.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// <reference types="mocha" />
import Benchmark = require('benchmark');
import _Global = require('./lib/global');
import registerGlobal from './lib/register';
export declare let defaultOptions: Readonly<Partial<defaultOptions>>;
export declare type IGlobal = typeof _Global;
export declare type defaultOptions<T = any, R = any> = {
versions?: [string, T][];
test?: Mocha.ITestDefinition;
suite?: Mocha.IContextDefinition;
prefix?: string;
Benchmark?: typeof Benchmark;
optionsBenchmark?: Benchmark.Options;
};
export declare function getOptions(options: defaultOptions): defaultOptions;
export declare class MochaBenchmarkClass<T, R> {
protected _data: {
options?: defaultOptions<T, R>;
};
constructor(options: defaultOptions<T, R>);
protected _init(): void;
readonly options: defaultOptions<T, R>;
suite(name: string, fn: IContextCompareCallback<T, R>): void;
static create<T>(options: defaultOptions<T>): MochaBenchmarkClass<T, any>;
}
export declare const create: typeof MochaBenchmarkClass.create;
import * as MochaBenchmark from './mocha_benchmark';
export default MochaBenchmark;
export { MochaBenchmark };
export declare type IContextCompareCallback<T = IGlobal, R = any> = (currentContext: Context<T, R>, currentData: T, vContext: Context<T, R>[]) => void;
export declare type IContextTestCallback<T = IGlobal, R = any, V extends any | void | Promise<any | void> = any | void | Promise<any | void>> = (deferred: Benchmark.Deferred, currentData: T, currentContext: Context<T, R>) => V;
export declare class Context<T = IGlobal, R = any> {
bench: Benchmark.Suite;
global: T | any;
prefix: string;
options: defaultOptions<T, R>;
isTopLevel?: boolean;
parent?: Context<T, R>;
name?: string;
index?: number;
data?: T;
_version?: [string, T];
vContexts?: Context<T, R>[];
constructor(bench: Benchmark.Suite, global: R | T, prefix: string, options: defaultOptions<T>);
it(name: string, test: IContextTestCallback<T, R>, options?: Benchmark.Options): void;
add(name: string, test: IContextTestCallback<T, R>, options?: Benchmark.Options): void;
test(name: string, test: IContextTestCallback<T, R>, options?: Benchmark.Options): void;
getPrefix(): string;
describe(name: string, suiteFn: IContextCompareCallback<T, R>): any;
describe(suiteFn: IContextCompareCallback<T, R>): any;
suite(name: string, suiteFn: IContextCompareCallback<T, R>): any;
suite(suiteFn: IContextCompareCallback<T, R>): any;
compare(name: string, suiteFn: IContextCompareCallback<T, R>): any;
compare(suiteFn: IContextCompareCallback<T, R>): any;
protected _compare(_name: string, suiteFn: IContextCompareCallback<T, R>): void;
}
export { registerGlobal };
export declare function getDefaultOptions<T>(): Partial<defaultOptions<T>>;