refactor: rename task performance computation methods
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 18:15:12 +0000 (20:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 18:15:12 +0000 (20:15 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/worker/abstract-worker.ts

index f40acf3786540eb350576612c068c4e851968449..d37c21571402e1d224c3c76a90acb0af595f21ef 100644 (file)
@@ -226,9 +226,10 @@ export abstract class AbstractWorker<
     message: MessageValue<Data>
   ): 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<Data, Response>,
     message: MessageValue<Data>
   ): 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<Data>): TaskPerformance {
+  private beginTaskPerformance (message: MessageValue<Data>): 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 && {