tachometer
Version:
Web benchmark runner
60 lines (59 loc) • 1.98 kB
TypeScript
/**
* @license
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt The complete set of authors may be found
* at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
* be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
* Google as part of the polymer project is also subject to an additional IP
* rights grant found at http://polymer.github.io/PATENTS.txt
*/
/// <reference types="node" />
import * as http from 'http';
import { BenchmarkResponse } from './types';
import { NpmInstall } from './versions';
export interface ServerOpts {
host: string;
ports: number[];
root: string;
npmInstalls: NpmInstall[];
mountPoints: MountPoint[];
resolveBareModules: boolean;
cache: boolean;
}
export interface MountPoint {
diskPath: string;
urlPath: string;
}
interface Session {
bytesSent: number;
userAgent: string;
}
export declare class Server {
readonly url: string;
readonly port: number;
private readonly server;
private session;
private deferredResults;
private readonly urlCache;
static start(opts: ServerOpts): Promise<Server>;
constructor(server: http.Server, opts: ServerOpts);
/**
* Mark the end of one session, return the data instrumented from it, and
* begin a new session.
*/
endSession(): Session;
nextResults(): Promise<BenchmarkResponse>;
close(): Promise<unknown>;
private instrumentRequests;
/**
* Cache all downstream middleware responses by URL in memory. This is
* especially helpful when bare module resolution is enabled, because that
* requires expensive parsing of all HTML and JavaScript that we really don't
* want to do for every benchmark sample.
*/
private cache;
private serveBenchLib;
private submitResults;
}
export {};