From c36e3cf0312f553b4b8c2b716da0d55cc87450cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 9 Jul 2023 13:03:20 +0200 Subject: [PATCH] refactor: cleanup performance statistics namespace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/performance/PerformanceStatistics.ts | 24 ++++++++++++------------ src/types/Statistics.ts | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index b4dc6012..317acf54 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -83,39 +83,39 @@ export class PerformanceStatistics { case MessageType.CALL_MESSAGE: if ( this.statistics.statisticsData.has(command) && - this.statistics.statisticsData.get(command)?.countRequest + this.statistics.statisticsData.get(command)?.requestCount ) { - ++this.statistics.statisticsData.get(command).countRequest; + ++this.statistics.statisticsData.get(command).requestCount; } else { this.statistics.statisticsData.set(command, { ...this.statistics.statisticsData.get(command), - countRequest: 1, + requestCount: 1, }); } break; case MessageType.CALL_RESULT_MESSAGE: if ( this.statistics.statisticsData.has(command) && - this.statistics.statisticsData.get(command)?.countResponse + this.statistics.statisticsData.get(command)?.responseCount ) { - ++this.statistics.statisticsData.get(command).countResponse; + ++this.statistics.statisticsData.get(command).responseCount; } else { this.statistics.statisticsData.set(command, { ...this.statistics.statisticsData.get(command), - countResponse: 1, + responseCount: 1, }); } break; case MessageType.CALL_ERROR_MESSAGE: if ( this.statistics.statisticsData.has(command) && - this.statistics.statisticsData.get(command)?.countError + this.statistics.statisticsData.get(command)?.errorCount ) { - ++this.statistics.statisticsData.get(command).countError; + ++this.statistics.statisticsData.get(command).errorCount; } else { this.statistics.statisticsData.set(command, { ...this.statistics.statisticsData.get(command), - countError: 1, + errorCount: 1, }); } break; @@ -205,8 +205,8 @@ export class PerformanceStatistics { } // Update current statistics this.statistics.updatedAt = new Date(); - this.statistics.statisticsData.get(entryName).countTimeMeasurement = - (this.statistics.statisticsData.get(entryName)?.countTimeMeasurement ?? 0) + 1; + this.statistics.statisticsData.get(entryName).timeMeasurementCount = + (this.statistics.statisticsData.get(entryName)?.timeMeasurementCount ?? 0) + 1; this.statistics.statisticsData.get(entryName).currentTimeMeasurement = entry.duration; this.statistics.statisticsData.get(entryName).minTimeMeasurement = Math.min( entry.duration, @@ -220,7 +220,7 @@ export class PerformanceStatistics { (this.statistics.statisticsData.get(entryName)?.totalTimeMeasurement ?? 0) + entry.duration; this.statistics.statisticsData.get(entryName).avgTimeMeasurement = this.statistics.statisticsData.get(entryName).totalTimeMeasurement / - this.statistics.statisticsData.get(entryName).countTimeMeasurement; + this.statistics.statisticsData.get(entryName).timeMeasurementCount; this.statistics.statisticsData.get(entryName)?.measurementTimeSeries instanceof CircularArray ? this.statistics.statisticsData .get(entryName) diff --git a/src/types/Statistics.ts b/src/types/Statistics.ts index ab2e826a..44c941e7 100644 --- a/src/types/Statistics.ts +++ b/src/types/Statistics.ts @@ -8,10 +8,10 @@ export type TimestampedData = { }; type StatisticsData = Partial<{ - countRequest: number; - countResponse: number; - countError: number; - countTimeMeasurement: number; + requestCount: number; + responseCount: number; + errorCount: number; + timeMeasurementCount: number; measurementTimeSeries: CircularArray; currentTimeMeasurement: number; minTimeMeasurement: number; -- 2.34.1