@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
57 lines • 1.62 kB
TypeScript
/**
* A class for managing a collection of metrics where each metric can store data and be accessed by name.
* Provides functionality to add, retrieve, list, and clear metrics.
*
* @example
* const metrics = new MetricCollection();
* metrics.create({name: "execution time"});
*
* // ... record metrics
* const t0 = performance.now();
* do_expensive_computation();
* const t1 = performance.now();
*
* metrics.get("execution time").record(t1 - t0);
*
* // ... read stats
* const stats = metrics.get("execution time").stats;
*
* console.log(`Average execution time: ${stats.mean}`);
*/
export class MetricCollection {
/**
* @private
* @type {Map<string, AbstractMetric>}
*/
private data;
/**
* Clear all data records.
* Note: does not remove any metrics, just the data within them
*/
clear(): void;
/**
* Get names of available metrics
* @returns {string[]}
*/
list(): string[];
/**
*
* @param {string} name
* @param {number} [buffer_size] The larger this number is - the more detail metric can hold. If you plan to compute statistics, this is your sample size.
* @returns {AbstractMetric}
*/
create({ name, buffer_size }: string): AbstractMetric;
/**
*
* @param {string} name
* @param {AbstractMetric} metric
*/
add(name: string, metric: AbstractMetric): void;
/**
*
* @param {string} name
* @returns {AbstractMetric|undefined}
*/
get(name: string): AbstractMetric | undefined;
}
//# sourceMappingURL=MetricCollection.d.ts.map