UNPKG

3.75 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 { BrowserConfig } from './browser';
12export declare class Deferred<T> {
13 readonly promise: Promise<T>;
14 resolve: (value: T) => void;
15 reject: (error: Error) => void;
16 constructor();
17}
18/**
19 * A mapping from NPM package name to version specifier, as used in a
20 * package.json's "dependencies" and "devDependencies".
21 */
22export interface PackageDependencyMap {
23 [pkg: string]: string;
24}
25/**
26 * Tachometer's extensions to the NPM "dependencies" field, which allows for
27 * more advanced configurations.
28 */
29export interface ExtendedPackageDependencyMap {
30 [pkg: string]: string | GitDependency;
31}
32/**
33 * Configuration for cloning a Git repo at some ref with an optional package
34 * sub-path for monorepos, for use as an NPM dependency.
35 */
36export interface GitDependency {
37 kind: 'git';
38 repo: string;
39 ref: string;
40 subdir?: string;
41 setupCommands?: string[];
42}
43/**
44 * The descriptor of a package version as specified by the --package-version
45 * flag.
46 */
47export interface PackageVersion {
48 label: string;
49 dependencyOverrides: ExtendedPackageDependencyMap;
50}
51/** The subset of the format of an NPM package.json file we care about. */
52export interface NpmPackageJson {
53 private: boolean;
54 dependencies: PackageDependencyMap;
55}
56/** The kinds of intervals we can measure. */
57export declare type Measurement = CallbackMeasurement | PerformanceEntryMeasurement | ExpressionMeasurement;
58export interface MeasurementBase {
59 name?: string;
60}
61export interface CallbackMeasurement extends MeasurementBase {
62 mode: 'callback';
63}
64export interface PerformanceEntryMeasurement extends MeasurementBase {
65 mode: 'performance';
66 entryName: string;
67}
68export interface ExpressionMeasurement extends MeasurementBase {
69 mode: 'expression';
70 expression: string;
71}
72export declare type CommandLineMeasurements = 'callback' | 'fcp' | 'global';
73export declare const measurements: Set<string>;
74/** A specification of a benchmark to run. */
75export interface BenchmarkSpec {
76 url: LocalUrl | RemoteUrl;
77 measurement: Measurement[];
78 name: string;
79 browser: BrowserConfig;
80}
81export interface LocalUrl {
82 kind: 'local';
83 version?: PackageVersion;
84 urlPath: string;
85 queryString: string;
86}
87export interface RemoteUrl {
88 kind: 'remote';
89 url: string;
90}
91export interface BenchmarkResponse {
92 millis: number;
93}
94/**
95 * Benchmark results for a particular measurement on a particular page, across
96 * all samples.
97 */
98export interface BenchmarkResult {
99 /**
100 * Label for this result. When there is more than one per page, this will
101 * contain both the page and measurement labels as "page [measurement]".
102 */
103 name: string;
104 /**
105 * The measurement that produced this result
106 */
107 measurement: Measurement;
108 /**
109 * A single page can return multiple measurements. The offset into the array
110 * of measurements in the spec that this particular result corresponds to.
111 */
112 measurementIndex: number;
113 /**
114 * Millisecond measurements for each sample.
115 */
116 millis: number[];
117 queryString: string;
118 version: string;
119 browser: BrowserConfig;
120 userAgent: string;
121 bytesSent: number;
122}