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,
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,
return fn
}
- private beforeTaskRunHook (message: MessageValue<Data>): TaskPerformance {
+ private beginTaskPerformance (message: MessageValue<Data>): TaskPerformance {
const timestamp = performance.now()
return {
timestamp,
}
}
- private afterTaskRunHook (taskPerformance: TaskPerformance): TaskPerformance {
+ private endTaskPerformance (
+ taskPerformance: TaskPerformance
+ ): TaskPerformance {
return {
...taskPerformance,
...(this.statistics.runTime && {