From: Jérôme Benoit Date: Tue, 6 Jun 2023 18:15:12 +0000 (+0200) Subject: refactor: rename task performance computation methods X-Git-Tag: v2.5.4~16^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d9d31201e7767e7936ee4d1c0b944ee71786d0bb;p=poolifier.git refactor: rename task performance computation methods Signed-off-by: Jérôme Benoit --- 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 && {