X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FPerformanceStatistics.ts;h=bcd0b71f69888318b1e5dfd35a2e2fc67757af2e;hb=396fa849e6977bbf094d51caa3616c09bebcc4e6;hp=9594fb3f24f1e1d989f0694c550c7b1ecd2db75a;hpb=bb80986b8d8724de94e2b307aef9b63c45cdfce3;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/PerformanceStatistics.ts b/src/utils/PerformanceStatistics.ts index 9594fb3f..bcd0b71f 100644 --- a/src/utils/PerformanceStatistics.ts +++ b/src/utils/PerformanceStatistics.ts @@ -1,7 +1,7 @@ +import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from './CircularArray'; import CommandStatistics, { CommandStatisticsData, PerfEntry } from '../types/CommandStatistics'; import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; -import CircularArray from './CircularArray'; import Configuration from './Configuration'; import { MessageType } from '../types/ocpp/MessageType'; import { PerformanceEntry } from 'perf_hooks'; @@ -112,13 +112,13 @@ export default class PerformanceStatistics { private addPerformanceTimer(command: RequestCommand | IncomingRequestCommand, duration: number): void { // Map to proper command name - const MAPCOMMAND = { + const MAP_COMMAND = { sendMeterValues: RequestCommand.METER_VALUES, startTransaction: RequestCommand.START_TRANSACTION, stopTransaction: RequestCommand.STOP_TRANSACTION, }; - if (MAPCOMMAND[command]) { - command = MAPCOMMAND[command] as RequestCommand | IncomingRequestCommand; + if (MAP_COMMAND[command]) { + command = MAP_COMMAND[command] as RequestCommand | IncomingRequestCommand; } // Initialize command statistics if (!this.commandsStatistics.commandsStatisticsData[command]) { @@ -131,7 +131,7 @@ export default class PerformanceStatistics { this.commandsStatistics.commandsStatisticsData[command].maxTimeMeasurement = this.commandsStatistics.commandsStatisticsData[command].maxTimeMeasurement ? (this.commandsStatistics.commandsStatisticsData[command].maxTimeMeasurement < duration ? duration : this.commandsStatistics.commandsStatisticsData[command].maxTimeMeasurement) : duration; this.commandsStatistics.commandsStatisticsData[command].totalTimeMeasurement = this.commandsStatistics.commandsStatisticsData[command].totalTimeMeasurement ? this.commandsStatistics.commandsStatisticsData[command].totalTimeMeasurement + duration : duration; this.commandsStatistics.commandsStatisticsData[command].avgTimeMeasurement = this.commandsStatistics.commandsStatisticsData[command].totalTimeMeasurement / this.commandsStatistics.commandsStatisticsData[command].countTimeMeasurement; - Array.isArray(this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries) ? this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries.push(duration) : this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries = [duration] as CircularArray; + Array.isArray(this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries) ? this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries.push(duration) : this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries = new CircularArray(DEFAULT_CIRCULAR_ARRAY_SIZE, duration); this.commandsStatistics.commandsStatisticsData[command].medTimeMeasurement = this.median(this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries); this.commandsStatistics.commandsStatisticsData[command].stdDevTimeMeasurement = this.stdDeviation(this.commandsStatistics.commandsStatisticsData[command].timeMeasurementSeries); }