UNPKG

1.99 kBTypeScriptView Raw
1import * as Benchmark from 'benchmark';
2import { Executor } from '../executors/Executor';
3import Reporter, { ReporterProperties } from './Reporter';
4import Test from '../Test';
5import Suite from '../Suite';
6export default class BenchmarkReporter extends Reporter implements BenchmarkReporterProperties {
7 baseline: BenchmarkBaseline;
8 filename: string;
9 mode: BenchmarkMode;
10 sessions: {
11 [sessionId: string]: SessionInfo;
12 };
13 thresholds: BenchmarkThresholds;
14 constructor(executor: Executor, options?: BenchmarkReporterOptions);
15 _getSession(testOrSuite: Test | Suite): SessionInfo;
16 runEnd(): void;
17 suiteEnd(suite: Suite): void;
18 suiteStart(suite: Suite): void;
19 testEnd(test: Test): void;
20}
21export interface BenchmarkData {
22 times: Benchmark.Times;
23 hz: number;
24 stats: {
25 rme: number;
26 moe: number;
27 mean: number;
28 };
29}
30export interface BenchmarkThresholds {
31 warn?: {
32 rme?: number;
33 hz?: number;
34 mean?: number;
35 };
36 fail?: {
37 rme?: number;
38 hz?: number;
39 mean?: number;
40 };
41}
42export interface BaselineEnvironment {
43 client: string;
44 version: string;
45 platform: string;
46 tests: {
47 [testId: string]: BenchmarkData;
48 };
49}
50export interface BenchmarkBaseline {
51 [key: string]: BaselineEnvironment;
52}
53export interface SesssionEnvironment {
54 client: string;
55 version: string;
56 platform: string;
57 id: string;
58}
59export interface SessionInfo {
60 suites: {
61 [suiteId: string]: {
62 numBenchmarks: number;
63 numFailedBenchmarks: number;
64 };
65 };
66 environment: SesssionEnvironment;
67}
68export declare type BenchmarkMode = 'baseline' | 'test';
69export interface BenchmarkReporterProperties extends ReporterProperties {
70 filename: string;
71 mode: BenchmarkMode;
72 thresholds: BenchmarkThresholds;
73}
74export declare type BenchmarkReporterOptions = Partial<BenchmarkReporterProperties>;