From: Jérôme Benoit Date: Wed, 28 Dec 2022 20:47:47 +0000 (+0100) Subject: Fixes to performance: X-Git-Tag: v1.1.89~52 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c60af6ca67ad2599e7e3e886f219da6323ead61b;p=e-mobility-charging-stations-simulator.git Fixes to performance: + Clear measure after usage + Log statistics map properly Signed-off-by: Jérôme Benoit --- diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index f3cc9e5f..8dae1bea 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -58,6 +58,7 @@ export default class PerformanceStatistics { public static endMeasure(name: string, markId: string): void { performance.measure(name, markId); performance.clearMarks(markId); + performance.clearMeasures(name); } public addRequestStatistic( @@ -127,6 +128,7 @@ export default class PerformanceStatistics { clearInterval(this.displayInterval); } performance.clearMarks(); + performance.clearMeasures(); this.performanceObserver?.disconnect(); } @@ -136,8 +138,8 @@ export default class PerformanceStatistics { } private initializePerformanceObserver(): void { - this.performanceObserver = new PerformanceObserver((list) => { - const lastPerformanceEntry = list.getEntries()[0]; + this.performanceObserver = new PerformanceObserver((performanceObserverList) => { + const lastPerformanceEntry = performanceObserverList.getEntries()[0]; this.addPerformanceEntryToStatistics(lastPerformanceEntry); logger.debug( `${this.logPrefix()} '${lastPerformanceEntry.name}' performance entry: %j`, @@ -148,7 +150,10 @@ export default class PerformanceStatistics { } private logStatistics(): void { - logger.info(this.logPrefix() + ' %j', this.statistics); + logger.info(`${this.logPrefix()}`, { + ...this.statistics, + statisticsData: Utils.JSONStringifyWithMapSupport(this.statistics.statisticsData), + }); } private startLogStatisticsInterval(): void { diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index f1744075..08e87320 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -259,7 +259,7 @@ export default class Utils { } public static JSONStringifyWithMapSupport( - obj: Record | Record[], + obj: Record | Record[] | Map, space?: number ): string { return JSON.stringify(