repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into feature/task-functions
[poolifier.git]
/
benchmarks
/
versus-external-pools
/
dynamic-node-worker-threads-pool.mjs
diff --git
a/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs
b/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs
index 204049749d2e171a1cb067ec550179cf65a124fa..c4be1ee1c6d1a0ca312d1597c1d8e4a48406d5fd 100644
(file)
--- a/
benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs
+++ b/
benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs
@@
-1,9
+1,7
@@
-// IMPORT LIBRARIES
import { DynamicPool } from 'node-worker-threads-pool'
import { DynamicPool } from 'node-worker-threads-pool'
-// FINISH IMPORT LIBRARIES
-// IMPORT FUNCTION TO BENCH
+import { executeAsyncFn } from './utils.mjs'
import functionToBench from './functions/function-to-bench.js'
import functionToBench from './functions/function-to-bench.js'
-// FINISH IMPORT FUNCTION TO BENCH
+
const size = parseInt(process.env.POOL_SIZE)
const iterations = parseInt(process.env.NUM_ITERATIONS)
const data = {
const size = parseInt(process.env.POOL_SIZE)
const iterations = parseInt(process.env.NUM_ITERATIONS)
const data = {
@@
-12,13
+10,13
@@
const data = {
taskSize: parseInt(process.env.TASK_SIZE)
}
taskSize: parseInt(process.env.TASK_SIZE)
}
-const
p
ool = new DynamicPool(size)
+const
dynamicP
ool = new DynamicPool(size)
async function run () {
async function run () {
- const promises =
[]
+ const promises =
new Set()
for (let i = 0; i < iterations; i++) {
for (let i = 0; i < iterations; i++) {
- promises.
push
(
-
p
ool.exec({
+ promises.
add
(
+
dynamicP
ool.exec({
task: functionToBench,
param: data,
timeout: 60000 // this is the same as poolifier default
task: functionToBench,
param: data,
timeout: 60000 // this is the same as poolifier default
@@
-30,4
+28,4
@@
async function run () {
process.exit()
}
process.exit()
}
-await
run(
)
+await
executeAsyncFn(run
)