taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f7582fd34f26ccdedac6ec391d503c3f8b699abe
parent b178f297ebb84eee9675a2007363a636fcc82d29
Author: Iván Ávalos <avalos@disroot.org>
Date:   Tue,  3 Feb 2026 18:21:46 +0100

taler-util: add count to performance stats, rename durationMs to maxDurationMs

Diffstat:
Mpackages/taler-util/src/performance.ts | 35+++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/packages/taler-util/src/performance.ts b/packages/taler-util/src/performance.ts @@ -37,28 +37,33 @@ export type PerformanceStat = | { type: PerformanceStatType.HttpFetch; url: string; - durationMs: number; + maxDurationMs: number; + count: number; } | { type: PerformanceStatType.DbQuery; name: string; location: string; - durationMs: number; + maxDurationMs: number; + count: number; } | { type: PerformanceStatType.Crypto; operation: string; - durationMs: number; + maxDurationMs: number; + count: number; } | { type: PerformanceStatType.WalletRequest; operation: string; - durationMs: number; + maxDurationMs: number; + count: number; } | { type: PerformanceStatType.WalletTask; taskId: string; - durationMs: number; + maxDurationMs: number; + count: number; }; export namespace PerformanceStat { @@ -72,7 +77,8 @@ export namespace PerformanceStat { return { type: PerformanceStatType.HttpFetch, url: evt.url, - durationMs: evt.durationMs, + maxDurationMs: evt.durationMs, + count: 1, }; } else if ( evt.type === ObservabilityEventType.DbQueryFinishSuccess || @@ -82,7 +88,8 @@ export namespace PerformanceStat { type: PerformanceStatType.DbQuery, name: evt.name, location: evt.location, - durationMs: evt.durationMs, + maxDurationMs: evt.durationMs, + count: 1, }; } else if ( evt.type === ObservabilityEventType.CryptoFinishSuccess || @@ -91,7 +98,8 @@ export namespace PerformanceStat { return { type: PerformanceStatType.Crypto, operation: evt.operation, - durationMs: evt.durationMs, + maxDurationMs: evt.durationMs, + count: 1, }; } else if ( evt.type === ObservabilityEventType.RequestFinishSuccess || @@ -100,13 +108,15 @@ export namespace PerformanceStat { return { type: PerformanceStatType.WalletRequest, operation: evt.operation, - durationMs: evt.durationMs, + maxDurationMs: evt.durationMs, + count: 1, }; } else if (evt.type === ObservabilityEventType.ShepherdTaskResult) { return { type: PerformanceStatType.WalletTask, taskId: evt.taskId, - durationMs: evt.durationMs, + maxDurationMs: evt.durationMs, + count: 1, }; } @@ -188,7 +198,8 @@ export namespace PerformanceTable { tab[stat.type]?.push(stat); } else { const existing = tab[stat.type]!![index]; - existing.durationMs = Math.max(existing.durationMs, stat.durationMs); + existing.maxDurationMs = Math.max(existing.maxDurationMs, stat.maxDurationMs); + existing.count += 1; tab[stat.type]!![index] = existing; } } @@ -199,7 +210,7 @@ export namespace PerformanceTable { function sort(tab: PerformanceTable) { for (const k of Object.keys(tab)) { const key = k as keyof typeof tab - tab[key]!!.sort((a, b) => b.durationMs - a.durationMs); + tab[key]!!.sort((a, b) => b.maxDurationMs - a.maxDurationMs); } }