repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
docs: refine benchmark README.md
[poolifier.git]
/
benchmarks
/
versus-external-pools
/
static-node-worker-threads-pool.mjs
diff --git
a/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs
b/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs
index b8a90ea321ccae3cf912b010ce8d4d21b30a7a53..d37677cdb1294190d9663365e0a39d89d986b973 100644
(file)
--- a/
benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs
+++ b/
benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs
@@
-1,9
+1,7
@@
-// IMPORT LIBRARIES
import { StaticPool } from 'node-worker-threads-pool'
import { StaticPool } from 'node-worker-threads-pool'
-// FINISH IMPORT LIBRARIES
-// IMPORT FUNCTION TO BENCH
+import { executeAsyncFn } from '../benchmarks-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,19
+10,19
@@
const data = {
taskSize: parseInt(process.env.TASK_SIZE)
}
taskSize: parseInt(process.env.TASK_SIZE)
}
-const
p
ool = new StaticPool({
+const
staticP
ool = new StaticPool({
size,
task: functionToBench
})
async function run () {
size,
task: functionToBench
})
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(data))
+ promises.
add(staticP
ool.exec(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
)