UNPKG

2.41 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
6 * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
7 * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
8 * Google as part of the polymer project is also subject to an additional IP
9 * rights grant found at http://polymer.github.io/PATENTS.txt
10 */
11import { BenchmarkResult } from './types';
12export interface ConfidenceInterval {
13 low: number;
14 high: number;
15}
16export interface SummaryStats {
17 size: number;
18 mean: number;
19 meanCI: ConfidenceInterval;
20 variance: number;
21 standardDeviation: number;
22 relativeStandardDeviation: number;
23}
24export interface ResultStats {
25 result: BenchmarkResult;
26 stats: SummaryStats;
27}
28export interface ResultStatsWithDifferences extends ResultStats {
29 differences: Array<Difference | null>;
30}
31export interface Difference {
32 absolute: ConfidenceInterval;
33 relative: ConfidenceInterval;
34}
35export declare function summaryStats(data: number[]): SummaryStats;
36/**
37 * Return whether the given confidence interval contains a value.
38 */
39export declare function intervalContains(interval: ConfidenceInterval, value: number): boolean;
40export interface Horizons {
41 absolute: number[];
42 relative: number[];
43}
44/**
45 * Return whether all difference confidence intervals are unambiguously located
46 * on one side or the other of all given horizon values.
47 *
48 * For example, given the horizons 0 and 1:
49 *
50 * <---> true
51 * <---> false
52 * <---> true
53 * <---> false
54 * <---> true
55 * <-----------> false
56 *
57 * |-------|-------|-------| ms difference
58 * -1 0 1 2
59 */
60export declare function horizonsResolved(resultStats: ResultStatsWithDifferences[], horizons: Horizons): boolean;
61/**
62 * Given an array of results, return a new array of results where each result
63 * has additional statistics describing how it compares to each other result.
64 */
65export declare function computeDifferences(stats: ResultStats[]): ResultStatsWithDifferences[];
66export declare function computeDifference(a: SummaryStats, b: SummaryStats): Difference;