X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2FPerformanceStatistics.ts;h=e90595225278d3a926059a2ca3ab7821b800d644;hb=6027002ff1398a1cb3bb55d4994e4615efded2c0;hp=3bb72ffa5f711b2b6c3c2af6d3e2501454503f45;hpb=94032f3e2e158defa0b264390c1155eb90c29c6a;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 3bb72ffa..e9059522 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -67,20 +67,19 @@ export class PerformanceStatistics { objName: string | undefined, uri: URL | undefined ): PerformanceStatistics | undefined { - const logPfx = logPrefix(' Performance statistics') if (objId == null) { const errMsg = 'Cannot get performance statistics instance without specifying object id' - logger.error(`${logPfx} ${errMsg}`) + logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) throw new BaseError(errMsg) } if (objName == null) { const errMsg = 'Cannot get performance statistics instance without specifying object name' - logger.error(`${logPfx} ${errMsg}`) + logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) throw new BaseError(errMsg) } if (uri == null) { const errMsg = 'Cannot get performance statistics instance without specifying object uri' - logger.error(`${logPfx} ${errMsg}`) + logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) throw new BaseError(errMsg) } if (!PerformanceStatistics.instances.has(objId)) { @@ -89,6 +88,15 @@ export class PerformanceStatistics { return PerformanceStatistics.instances.get(objId) } + public static deleteInstance (objId: string | undefined): boolean { + if (objId == null) { + const errMsg = 'Cannot delete performance statistics instance without specifying object id' + logger.error(`${PerformanceStatistics.logPrefix()} ${errMsg}`) + throw new BaseError(errMsg) + } + return PerformanceStatistics.instances.delete(objId) + } + public static beginMeasure (id: string): string { const markId = `${id.charAt(0).toUpperCase()}${id.slice(1)}~${generateUUID()}` performance.mark(markId) @@ -308,6 +316,10 @@ export class PerformanceStatistics { } } + private static readonly logPrefix = (): string => { + return logPrefix(' Performance statistics') + } + private readonly logPrefix = (): string => { return logPrefix(` ${this.objName} | Performance statistics`) }