From: Jérôme Benoit Date: Sun, 9 Jul 2023 12:33:24 +0000 (+0200) Subject: refactor: add task function name to task performance X-Git-Tag: v2.6.13~18 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=197b4aa5aa76186bbe6f9274d455f4bdb8baa637;p=poolifier.git refactor: add task function name to task performance Signed-off-by: Jérôme Benoit --- diff --git a/src/utility-types.ts b/src/utility-types.ts index a8da491e..d7477319 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -24,6 +24,10 @@ export interface TaskError { * @internal */ export interface TaskPerformance { + /** + * Task name. + */ + readonly name: string /** * Task performance timestamp. */ diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 138719a1..a0154115 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -251,7 +251,7 @@ export abstract class AbstractWorker< message: MessageValue ): void { try { - let taskPerformance = this.beginTaskPerformance() + let taskPerformance = this.beginTaskPerformance(message.name) const res = fn(message.data) taskPerformance = this.endTaskPerformance(taskPerformance) this.sendToMainWorker({ @@ -332,9 +332,10 @@ export abstract class AbstractWorker< return fn } - private beginTaskPerformance (): TaskPerformance { + private beginTaskPerformance (name?: string): TaskPerformance { this.checkStatistics() return { + name: name ?? DEFAULT_FUNCTION_NAME, timestamp: performance.now(), ...(this.statistics.elu && { elu: performance.eventLoopUtilization() }) }