UNPKG

3.21 kBTypeScriptView Raw
1/********************************************************************************
2* Copyright (c) 2021 STMicroelectronics and others.
3*
4* This program and the accompanying materials are made available under the
5* terms of the Eclipse Public License 2.0 which is available at
6* http://www.eclipse.org/legal/epl-2.0.
7*
8* This Source Code may also be made available under the following Secondary
9* Licenses when the conditions for such availability set forth in the Eclipse
10* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11* with the GNU Classpath Exception which is available at
12* https://www.gnu.org/software/classpath/license.html.
13*
14* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15*******************************************************************************/
16import { Measurement, MeasurementOptions } from './measurement';
17import { Stopwatch } from './stopwatch';
18export declare const BackendStopwatch: unique symbol;
19/** API path of the stopwatch service that exposes the back-end stopwatch to clients. */
20export declare const stopwatchPath = "/services/stopwatch";
21/** Token representing a remote measurement in the {@link BackendStopwatch} protocol. */
22export declare type RemoteMeasurement = number;
23export declare const BackendStopwatchOptions: unique symbol;
24/**
25 * A service that exposes the back-end's {@link Stopwatch} to clients
26 * via the remote API. If you do not need this service then bind or re-bind
27 * the {@link NullBackendStopwatch} implementation to this service interface.
28 */
29export interface BackendStopwatch {
30 /**
31 * Create a {@link Measurement} that will compute the time that elapsed on the back-end when logged.
32 *
33 * @param name the {@link Measurement.name measurement name}
34 * @param options optional configuration of the new measurement
35 * @returns a token identifying an unique self-timing measurement relative to the back-end's timeline
36 */
37 start(name: string, options?: MeasurementOptions): Promise<RemoteMeasurement>;
38 /**
39 * Stop a measurement previously {@link start started} and log in the back-end a measurement of
40 * its duration relative to the back-end's timeline.
41 *
42 * @param measurement token identifying a measurement previously {@link start started}
43 * @param message a message to log
44 * @param messageArgs optional arguments to the `message`
45 */
46 stop(measurement: RemoteMeasurement, message: string, messageArgs: any[]): Promise<void>;
47}
48/**
49 * Default implementation of the (remote) back-end stopwatch service.
50 */
51export declare class DefaultBackendStopwatch {
52 readonly measurements: Map<number, Measurement>;
53 protected idSequence: number;
54 protected readonly stopwatch: Stopwatch;
55 start(name: string, options?: MeasurementOptions): RemoteMeasurement;
56 stop(measurementToken: RemoteMeasurement, message: string, messageArgs: any[]): void;
57}
58/**
59 * No-op implementation of the (remote) back-end stopwatch service.
60 */
61export declare class NullBackendStopwatch implements BackendStopwatch {
62 start(): Promise<RemoteMeasurement>;
63 stop(): Promise<void>;
64}
65//# sourceMappingURL=measurement-protocol.d.ts.map
\No newline at end of file