UNPKG

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