@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
36 lines (35 loc) • 1.28 kB
TypeScript
export interface IStoppableStopwatch {
/** Stop the given stopwatch. */
stop(): void;
}
/**
* Allows to measure keys of type `T` with a `Stopwatch`.
*
* Measure with {@link start}, {@link measure} or {@link measureAsync}, retrieve the final measurements with {@link get}.
*/
export declare class Measurements<T> {
private measurements;
/**
* Start a timer for the given key, and guards that this is the first time this key is started.
* Call {@link IStoppableStopwatch#stop} on the returned stopwatch to stop the timer.
*/
start(key: T): IStoppableStopwatch;
/**
* Automatically call {@link Measurements#start | start} and the corresponding stop to measure the execution time of the given function.
* @see {@link measureAsync}
*/
measure<Out>(key: T, fn: () => Out): Out;
/**
* Similar to {@link measure}, but await the promise as part of the measurement
*
* @param key - The key to write the resulting measurement to
* @param fn - The function to measure
*
* @see measure
*/
measureAsync<Out>(key: T, fn: () => Promise<Out>): Promise<Out>;
/**
* Retrieve all measure-results, requires that all stop-watches that have been started have also been stopped.
*/
get(): Map<T, bigint>;
}