+import CircularArray from '../utils/CircularArray';
import { EntryType } from 'perf_hooks';
export interface PerfEntry {
countResponse: number;
countError: number;
countTimeMeasurement: number;
- timeMeasurementSeries: number[];
+ timeMeasurementSeries: CircularArray<number>;
currentTimeMeasurement: number;
minTimeMeasurement: number;
maxTimeMeasurement: number;
--- /dev/null
+import Constants from './Constants';
+
+export default class CircularArray<T> extends Array<T> {
+ public size: number;
+
+ constructor(size: number = Constants.MAXIMUM_MEASUREMENTS_NUMBER) {
+ super();
+ this.size = size;
+ }
+
+ push(...items: T[]): number {
+ while (this.length > this.size) {
+ this.shift();
+ }
+ return super.push(...items);
+ }
+
+ unshift(...items: T[]): number {
+ while (this.length > this.size) {
+ this.pop();
+ }
+ return super.unshift(...items);
+ }
+}
static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms
static readonly CHARGING_STATION_ATG_WAIT_TIME = 2000; // Ms
+ static readonly MAXIMUM_MEASUREMENTS_NUMBER = 5000;
+
static readonly TRANSACTION_DEFAULT_IDTAG = '00000000';
}
import CommandStatistics, { CommandStatisticsData, PerfEntry } from '../types/CommandStatistics';
+import CircularArray from './CircularArray';
import Configuration from './Configuration';
import Constants from './Constants';
import { PerformanceEntry } from 'perf_hooks';
this._commandsStatistics[command].maxTimeMeasurement = this._commandsStatistics[command].maxTimeMeasurement ? (this._commandsStatistics[command].maxTimeMeasurement < duration ? duration : this._commandsStatistics[command].maxTimeMeasurement) : duration;
this._commandsStatistics[command].totalTimeMeasurement = this._commandsStatistics[command].totalTimeMeasurement ? this._commandsStatistics[command].totalTimeMeasurement + duration : duration;
this._commandsStatistics[command].avgTimeMeasurement = this._commandsStatistics[command].totalTimeMeasurement / this._commandsStatistics[command].countTimeMeasurement;
- Array.isArray(this._commandsStatistics[command].timeMeasurementSeries) ? this._commandsStatistics[command].timeMeasurementSeries.push(duration) : this._commandsStatistics[command].timeMeasurementSeries = [duration];
+ Array.isArray(this._commandsStatistics[command].timeMeasurementSeries) ? this._commandsStatistics[command].timeMeasurementSeries.push(duration) : this._commandsStatistics[command].timeMeasurementSeries = [duration] as CircularArray<number>;
this._commandsStatistics[command].medTimeMeasurement = this.median(this._commandsStatistics[command].timeMeasurementSeries);
}