+ .then(res => {
+ if (tasks === executions) {
+ return console.log(
+ `worker threads pool take ${
+ Date.now() - time
+ }ms to work on ${executions} tasks`
+ )
+ }
+ return null
+ })
+ .catch(err => console.error(err))
+ }
+}
+
+async function workerpoolTest () {
+ let executions = 0
+ const time = Date.now()
+ for (let i = 0; i <= tasks; i++) {
+ workerPool
+ .exec('yourFunction', [workerData])
+ .then(res => {
+ executions++
+ if (tasks === executions) {
+ return console.log(
+ `workerpool take ${
+ Date.now() - time
+ }ms to work on ${executions} tasks`
+ )
+ }
+ return null
+ })
+ .catch(err => console.error(err))