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 typescript
[poolifier.git]
/
benchmarks
/
versus-external-pools
/
dynamic-worker-nodes.js
diff --git
a/benchmarks/versus-external-pools/dynamic-worker-nodes.js
b/benchmarks/versus-external-pools/dynamic-worker-nodes.js
index 6b860d5f1ad9f959eeece37d54c1b0b3d364b5ad..7a77d88278877f1acdcc037b8cd55717c76759ee 100644
(file)
--- a/
benchmarks/versus-external-pools/dynamic-worker-nodes.js
+++ b/
benchmarks/versus-external-pools/dynamic-worker-nodes.js
@@
-1,29
+1,40
@@
+'use strict'
// IMPORT LIBRARIES
const WorkerNodes = require('worker-nodes')
// FINISH IMPORT LIBRARIES
// IMPORT LIBRARIES
const WorkerNodes = require('worker-nodes')
// FINISH IMPORT LIBRARIES
-const size =
Number
(process.env.POOL_SIZE)
-const iterations =
Number
(process.env.NUM_ITERATIONS)
+const size =
parseInt
(process.env.POOL_SIZE)
+const iterations =
parseInt
(process.env.NUM_ITERATIONS)
const data = {
test: 'MYBENCH',
const data = {
test: 'MYBENCH',
- taskType: process.env['TASK_TYPE']
+ taskType: process.env.TASK_TYPE,
+ taskSize: parseInt(process.env.TASK_SIZE)
}
const workerNodes = new WorkerNodes(
require.resolve('./workers/worker-nodes/function-to-bench-worker'),
{
}
const workerNodes = new WorkerNodes(
require.resolve('./workers/worker-nodes/function-to-bench-worker'),
{
- minWorkers:
size
,
- maxWorkers: size
* 3
,
+ minWorkers:
Math.floor(size / 2)
,
+ maxWorkers: size,
taskTimeout: 60000 // this is the same as poolifier default
}
)
async function run () {
taskTimeout: 60000 // this is the same as poolifier default
}
)
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
(workerNodes.call.functionToBench(data))
+ promises.
add
(workerNodes.call.functionToBench(data))
}
await Promise.all(promises)
}
await Promise.all(promises)
+ // eslint-disable-next-line n/no-process-exit
process.exit()
}
process.exit()
}
-run()
+(async () => {
+ try {
+ await run()
+ } catch (e) {
+ console.error(e)
+ // eslint-disable-next-line n/no-process-exit
+ process.exit(1)
+ }
+})()