repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): bump @types/node
[poolifier.git]
/
benchmarks
/
versus-external-pools
/
dynamic-poolifier.mjs
diff --git
a/benchmarks/versus-external-pools/dynamic-poolifier.mjs
b/benchmarks/versus-external-pools/dynamic-poolifier.mjs
index 34adba055629ea518de1c0d3de7df2e36311447b..98d210062d76a354cdec859486a49bcc0290e0eb 100644
(file)
--- a/
benchmarks/versus-external-pools/dynamic-poolifier.mjs
+++ b/
benchmarks/versus-external-pools/dynamic-poolifier.mjs
@@
-1,6
+1,6
@@
-// IMPORT LIBRARIES
import { DynamicThreadPool } from 'poolifier'
import { DynamicThreadPool } from 'poolifier'
-// FINISH IMPORT LIBRARIES
+import { executeAsyncFn } from './utils.mjs'
+
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 = {
@@
-9,20
+9,23
@@
const data = {
taskSize: parseInt(process.env.TASK_SIZE)
}
taskSize: parseInt(process.env.TASK_SIZE)
}
-const dynamicPool = new DynamicThreadPool(
+const dynamicThreadPool = new DynamicThreadPool(
+ Math.floor(size / 2),
size,
size,
- size * 3,
- './workers/poolifier/function-to-bench-worker.mjs'
+ './workers/poolifier/function-to-bench-worker.mjs',
+ {
+ enableTasksQueue: false
+ }
)
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(dynamic
Pool.execute(data))
+ promises.
add(dynamicThread
Pool.execute(data))
}
await Promise.all(promises)
// eslint-disable-next-line n/no-process-exit
process.exit()
}
}
await Promise.all(promises)
// eslint-disable-next-line n/no-process-exit
process.exit()
}
-await
run(
)
+await
executeAsyncFn(run
)