- const performanceJSONFilePath = path.join(path.resolve(__dirname, '../../../'), this.storageURI.pathname.replace(/(?:^\/)|(?:\/$)/g, ''));
- fs.appendFile(performanceJSONFilePath, JSON.stringify(performanceStatistics, null, 2), 'utf8', (err) => {
- if (err) {
- FileUtils.handleFileException(this.logPrefix, 'Performance measurements', performanceJSONFilePath, err);
+ this.checkPerformanceRecordsFile();
+ fs.readFile(this.dbName, 'utf-8', (error, data) => {
+ if (error) {
+ FileUtils.handleFileException(this.logPrefix, Constants.PERFORMANCE_RECORDS_FILETYPE, this.dbName, error);
+ } else {
+ const performanceRecords: Statistics[] = data ? JSON.parse(data) as Statistics[] : [];
+ performanceRecords.push(performanceStatistics);
+ fs.writeFile(this.dbName, JSON.stringify(performanceRecords, null, 2), 'utf-8', (err) => {
+ if (err) {
+ FileUtils.handleFileException(this.logPrefix, Constants.PERFORMANCE_RECORDS_FILETYPE, this.dbName, err);
+ }
+ });