UNPKG

1.65 kBTypeScriptView Raw
1import { CancellablePromise } from '@theintern/common';
2import Benchmark from 'benchmark';
3import Test, { TestFunction, TestProperties } from './Test';
4import Deferred from './Deferred';
5export default class BenchmarkTest extends Test {
6 test: BenchmarkTestFunction;
7 benchmark: InternBenchmark;
8 constructor(descriptor: BenchmarkTestOptions);
9 get timeElapsed(): number;
10 set timeElapsed(_value: number);
11 async(_timeout?: number, _numCallsUntilResolution?: number): Deferred<any>;
12 run(): CancellablePromise<void>;
13 toJSON(): {
14 [key: string]: any;
15 };
16 static async(testFunction: BenchmarkDeferredTestFunction, numCallsUntilResolution?: number): BenchmarkTestFunction;
17}
18export interface BenchmarkTestFunction extends TestFunction {
19 (this: BenchmarkTest): void | Promise<any>;
20 options?: BenchmarkOptions;
21}
22export interface BenchmarkDeferredTestFunction extends BenchmarkTestFunction {
23 (this: BenchmarkTest, deferred: Deferred<void>): void | Promise<any>;
24 options?: BenchmarkOptions;
25}
26export interface BenchmarkTestProperties extends TestProperties {
27 test: BenchmarkTestFunction;
28 skip: string;
29 numCallsUntilResolution: number;
30}
31export declare type BenchmarkTestOptions = Partial<BenchmarkTestProperties> & {
32 name: string;
33 test: BenchmarkTestFunction;
34 options?: BenchmarkOptions;
35};
36export interface BenchmarkOptions extends Benchmark.Options {
37 skip?: string;
38 numCallsUntilResolution?: number;
39}
40export interface InternBenchmark extends Benchmark {
41 internTest?: BenchmarkTest;
42}
43export declare function isBenchmarkTest(value: any): value is BenchmarkTest;