UNPKG

@snap/camera-kit

Version:
27 lines 1.63 kB
import { __awaiter } from "tslib"; import { Injectable } from "@snap/ts-inject"; import { metricsClientFactory } from "../../clients/metricsClient"; import { configurationToken } from "../../configuration"; import { TypedCustomEvent } from "../../events/TypedCustomEvent"; import { metricsEventTargetFactory } from "../metricsEventTarget"; import { Histogram } from "../operational/Histogram"; const reportableBenchmarks = ["gflops"]; export const reportBenchmarks = Injectable("reportBenchmarks", [metricsEventTargetFactory.token, metricsClientFactory.token, configurationToken], (metricsEventTarget, metrics, config) => __awaiter(void 0, void 0, void 0, function* () { if (config.lensPerformance === undefined) return; const lensPerformance = yield config.lensPerformance; const baseBenchmark = { name: "benchmarkComplete", performanceCluster: `${lensPerformance.cluster}`, webglRendererInfo: lensPerformance.webglRendererInfo, }; const dimensions = { performance_cluster: lensPerformance.cluster.toString() }; for (const benchmark of lensPerformance.benchmarks) { if (!reportableBenchmarks.includes(benchmark.name)) continue; const benchmarkComplete = Object.assign(Object.assign({}, baseBenchmark), { benchmarkName: benchmark.name, benchmarkValue: benchmark.value }); metricsEventTarget.dispatchEvent(new TypedCustomEvent("benchmarkComplete", benchmarkComplete)); metrics.setOperationalMetrics(Histogram.level(`benchmark.${benchmark.name}`, benchmark.value, dimensions)); } })); //# sourceMappingURL=reportBenchmarks.js.map