--- /dev/null
+// IMPORT LIBRARIES
+import { ThreadPool } from 'nanothreads'
+// FINISH IMPORT LIBRARIES
+// IMPORT FUNCTION TO BENCH
+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 = {
+ test: 'MYBENCH',
+ taskType: process.env.TASK_TYPE,
+ taskSize: parseInt(process.env.TASK_SIZE)
+}
+
+const threadPool = new ThreadPool({
+ task: functionToBench,
+ count: size
+})
+
+async function run () {
+ const promises = new Set()
+ for (let i = 0; i < iterations; i++) {
+ promises.add(threadPool.exec(data))
+ }
+ await Promise.all(promises)
+ // eslint-disable-next-line n/no-process-exit
+ process.exit()
+}
+
+await run()
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
+ "nanothreads": "0.3.7",
"node-worker-threads-pool": "1.5.1",
"piscina": "4.0.0",
"poolifier": "2.6.8",
- "tinypool": "0.6.0",
+ "tinypool": "0.7.0",
"worker-nodes": "2.6.0",
"workerpool": "6.4.0"
}
excludeLinksFromLockfile: false
dependencies:
+ nanothreads:
+ specifier: 0.3.7
+ version: 0.3.7
node-worker-threads-pool:
specifier: 1.5.1
version: 1.5.1
specifier: 2.6.8
version: 2.6.8
tinypool:
- specifier: 0.6.0
- version: 0.6.0
+ specifier: 0.7.0
+ version: 0.7.0
worker-nodes:
specifier: 2.6.0
version: 2.6.0
isarray: 1.0.0
dev: false
+ /nanothreads@0.3.7:
+ resolution: {integrity: sha512-l/gbxnQBeMGspLoa+JKhqDrsBtqMW4G5ElsEgbVigR5gl6IBHzBjpM7URGeu0UQN4k7DK0o+J3GmHgaXv+aDQw==}
+ dev: false
+
/nice-napi@1.0.2:
resolution: {integrity: sha512-px/KnJAJZf5RuBGcfD+Sp2pAKq0ytz8j+1NehvgIGFkvtvFrDM3T8E4x/JJODXK9WZow8RRGrbA9QQ3hs+pDhA==}
os: ['!win32']
requiresBuild: true
dev: false
- /tinypool@0.6.0:
- resolution: {integrity: sha512-FdswUUo5SxRizcBc6b1GSuLpLjisa8N8qMyYoP3rl+bym+QauhtJP5bvZY1ytt8krKGmMLYIRl36HBZfeAoqhQ==}
+ /tinypool@0.7.0:
+ resolution: {integrity: sha512-zSYNUlYSMhJ6Zdou4cJwo/p7w5nmAH17GRfU/ui3ctvjXFErXXkruT4MWW6poDeXgCaIBlGLrfU6TbTXxyGMww==}
engines: {node: '>=14.0.0'}
dev: false