X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2FPerformanceStatistics.ts;h=f3cc9e5fb67a132476cbba261739f9c450befa89;hb=5f7e72c1538ebf67dc5de3c29840f7b4da6704f8;hp=c41b2d59a2e0d157758e7b37643f34d8e17f90ad;hpb=32de5a575189d226213641f5ee36004f8454cb50;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index c41b2d59..f3cc9e5f 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -1,13 +1,13 @@ // Partial Copyright Jerome Benoit. 2021. All Rights Reserved. import { PerformanceEntry, PerformanceObserver, performance } from 'perf_hooks'; -import { URL } from 'url'; +import type { URL } from 'url'; import { parentPort } from 'worker_threads'; import { MessageChannelUtils } from '../charging-station/MessageChannelUtils'; import { MessageType } from '../types/ocpp/MessageType'; -import { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; -import Statistics, { StatisticsData, TimeSeries } from '../types/Statistics'; +import type { IncomingRequestCommand, RequestCommand } from '../types/ocpp/Requests'; +import type { Statistics, StatisticsData, TimeSeries } from '../types/Statistics'; import { CircularArray, DEFAULT_CIRCULAR_ARRAY_SIZE } from '../utils/CircularArray'; import Configuration from '../utils/Configuration'; import logger from '../utils/Logger'; @@ -172,7 +172,7 @@ export default class PerformanceStatistics { } private median(dataSet: number[]): number { - if (Array.isArray(dataSet) && dataSet.length === 1) { + if (Array.isArray(dataSet) === true && dataSet.length === 1) { return dataSet[0]; } const sortedDataSet = dataSet.slice().sort((a, b) => a - b); @@ -220,12 +220,7 @@ export default class PerformanceStatistics { } private addPerformanceEntryToStatistics(entry: PerformanceEntry): void { - let entryName = entry.name; - // Rename entry name - const MAP_NAME: Record = {}; - if (MAP_NAME[entryName]) { - entryName = MAP_NAME[entryName]; - } + const entryName = entry.name; // Initialize command statistics if (!this.statistics.statisticsData.has(entryName)) { this.statistics.statisticsData.set(entryName, {}); @@ -256,7 +251,7 @@ export default class PerformanceStatistics { this.statistics.statisticsData.get(entryName).avgTimeMeasurement = this.statistics.statisticsData.get(entryName).totalTimeMeasurement / this.statistics.statisticsData.get(entryName).countTimeMeasurement; - Array.isArray(this.statistics.statisticsData.get(entryName).timeMeasurementSeries) + Array.isArray(this.statistics.statisticsData.get(entryName).timeMeasurementSeries) === true ? this.statistics.statisticsData .get(entryName) .timeMeasurementSeries.push({ timestamp: entry.startTime, value: entry.duration })