refactor: cleanup performance statistics namespace
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 9 Jul 2023 11:03:20 +0000 (13:03 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 9 Jul 2023 11:03:20 +0000 (13:03 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/performance/PerformanceStatistics.ts
src/types/Statistics.ts

index b4dc60125c378e00031aca42a6a6fee4c9c8fedc..317acf54025ba8abcbd19c36eaf516df36c8600b 100644 (file)
@@ -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)
index ab2e826ae147039d96ae37b1ad5813ec589ddb89..44c941e70bee6e2b7ee828f657c75463a5ffef73 100644 (file)
@@ -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<TimestampedData>;
   currentTimeMeasurement: number;
   minTimeMeasurement: number;