From: Jérôme Benoit Date: Tue, 15 Mar 2022 14:56:52 +0000 (+0100) Subject: Measure performance of template or configuration file operations X-Git-Tag: v1.1.56~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=42a3eee7406d9ebfe5afd43c3065345701542d67;p=e-mobility-charging-stations-simulator.git Measure performance of template or configuration file operations Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 32d4542a..118805fe 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -771,7 +771,10 @@ export default class ChargingStation { private getTemplateFromFile(): ChargingStationTemplate | null { let template: ChargingStationTemplate = null; try { + const measureId = `${FileType.ChargingStationTemplate} read`; + const beginId = PerformanceStatistics.beginMeasure(measureId); template = JSON.parse(fs.readFileSync(this.templateFile, 'utf8')) as ChargingStationTemplate; + PerformanceStatistics.endMeasure(measureId, beginId); } catch (error) { FileUtils.handleFileException( this.logPrefix(), @@ -1157,9 +1160,14 @@ export default class ChargingStation { let configuration: ChargingStationConfiguration = null; if (this.configurationFile && fs.existsSync(this.configurationFile)) { try { + const measureId = `${FileType.ChargingStationConfiguration} read`; + const beginId = PerformanceStatistics.beginMeasure( + `${FileType.ChargingStationConfiguration} read` + ); configuration = JSON.parse( fs.readFileSync(this.configurationFile, 'utf8') ) as ChargingStationConfiguration; + PerformanceStatistics.endMeasure(measureId, beginId); } catch (error) { FileUtils.handleFileException( this.logPrefix(), @@ -1192,9 +1200,12 @@ export default class ChargingStation { configurationData.stationInfo = this.stationInfo; break; } + const measureId = `${FileType.ChargingStationConfiguration} write`; + const beginId = PerformanceStatistics.beginMeasure(measureId); const fileDescriptor = fs.openSync(this.configurationFile, 'w'); fs.writeFileSync(fileDescriptor, JSON.stringify(configurationData, null, 2), 'utf8'); fs.closeSync(fileDescriptor); + PerformanceStatistics.endMeasure(measureId, beginId); } catch (error) { FileUtils.handleFileException( this.logPrefix(),