-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathtypes.ts
45 lines (35 loc) · 1.14 KB
/
types.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
import type { SuiteAPI, ExpectStatic, TestAPI } from 'vitest';
export interface BenchmarkCase {
readonly moduleName: string;
// execute the actual benchmark function
run(): void;
// run the benchmarks vitest test
test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI): void;
}
export abstract class Benchmark<Fn> implements BenchmarkCase {
// name of the module that is benchmarked
readonly moduleName: string;
// the function that implements the benchmark
readonly fn: Fn;
constructor(moduleName: string, fn: Fn) {
this.moduleName = moduleName;
this.fn = fn;
}
// execute the actual benchmark function
abstract run(): void;
// run the benchmarks vitest test
abstract test(describe: SuiteAPI, expect: ExpectStatic, test: TestAPI): void;
}
// Aliased any.
// Need to use ´any` for libraries that do not accept `unknown` as data input
// to their parse/assert functions.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type UnknownData = any;
export interface BenchmarkResult {
name: string;
benchmark: string;
runtime: string;
runtimeVersion: string;
ops: number;
margin: number;
}