+ private addPerformanceTimer(command: string, duration: number): void {
+ // Map to proper command name
+ const MAPCOMMAND = {
+ sendMeterValues: 'MeterValues',
+ startTransaction: 'StartTransaction',
+ stopTransaction: 'StopTransaction',
+ };
+ if (MAPCOMMAND[command]) {
+ command = MAPCOMMAND[command] as string;
+ }
+ // Initialize command statistics
+ if (!this._commandsStatistics[command]) {
+ this._commandsStatistics[command] = {} as CommandStatisticsData;
+ }
+ // Update current statistics timers
+ this._commandsStatistics[command].countTime = this._commandsStatistics[command].countTime ? this._commandsStatistics[command].countTime + 1 : 1;
+ this._commandsStatistics[command].minTime = this._commandsStatistics[command].minTime ? (this._commandsStatistics[command].minTime > duration ? duration : this._commandsStatistics[command].minTime) : duration;
+ this._commandsStatistics[command].maxTime = this._commandsStatistics[command].maxTime ? (this._commandsStatistics[command].maxTime < duration ? duration : this._commandsStatistics[command].maxTime) : duration;
+ this._commandsStatistics[command].totalTime = this._commandsStatistics[command].totalTime ? this._commandsStatistics[command].totalTime + duration : duration;
+ this._commandsStatistics[command].avgTime = this._commandsStatistics[command].totalTime / this._commandsStatistics[command].countTime;
+ }
+