From d9d31201e7767e7936ee4d1c0b944ee71786d0bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 6 Jun 2023 20:15:12 +0200 Subject: [PATCH] refactor: rename task performance computation methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/worker/abstract-worker.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index f40acf37..d37c2157 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -226,9 +226,10 @@ export abstract class AbstractWorker< message: MessageValue ): void { try { - const taskPerformance = this.beforeTaskRunHook(message) + const taskPerformance = this.beginTaskPerformance(message) const res = fn(message.data) - const { runTime, waitTime, elu } = this.afterTaskRunHook(taskPerformance) + const { runTime, waitTime, elu } = + this.endTaskPerformance(taskPerformance) this.sendToMainWorker({ data: res, runTime, @@ -258,11 +259,11 @@ export abstract class AbstractWorker< fn: WorkerAsyncFunction, message: MessageValue ): void { - const taskPerformance = this.beforeTaskRunHook(message) + const taskPerformance = this.beginTaskPerformance(message) fn(message.data) .then(res => { const { runTime, waitTime, elu } = - this.afterTaskRunHook(taskPerformance) + this.endTaskPerformance(taskPerformance) this.sendToMainWorker({ data: res, runTime, @@ -300,7 +301,7 @@ export abstract class AbstractWorker< return fn } - private beforeTaskRunHook (message: MessageValue): TaskPerformance { + private beginTaskPerformance (message: MessageValue): TaskPerformance { const timestamp = performance.now() return { timestamp, @@ -311,7 +312,9 @@ export abstract class AbstractWorker< } } - private afterTaskRunHook (taskPerformance: TaskPerformance): TaskPerformance { + private endTaskPerformance ( + taskPerformance: TaskPerformance + ): TaskPerformance { return { ...taskPerformance, ...(this.statistics.runTime && { -- 2.34.1