From: Jérôme Benoit Date: Sun, 9 Jul 2023 11:03:20 +0000 (+0200) Subject: refactor: cleanup performance statistics namespace X-Git-Tag: v1.2.18~59 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c36e3cf0312f553b4b8c2b716da0d55cc87450cf;p=e-mobility-charging-stations-simulator.git refactor: cleanup performance statistics namespace Signed-off-by: Jérôme Benoit --- 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;