'node fixed-piscina.js' \
'node dynamic-poolifier.js' \
'node fixed-poolifier.js' \
- 'node static-suchmokuo-node-worker-threads-pool.js' \
'node dynamic-suchmokuo-node-worker-threads-pool.js' \
- 'node threadjs.js'
+ 'node static-suchmokuo-node-worker-threads-pool.js' \
+ 'node threadjs.js' \
+ 'node dynamic-workerpool.js' \
+ 'node fixed-workerpool.js'
// IMPORT LIBRARIES
-const { FixedThreadPool, DynamicThreadPool } = require('poolifier')
+const { DynamicThreadPool } = require('poolifier')
// FINISH IMPORT LIBRARIES
const size = process.env.POOL_SIZE
const iterations = process.env.NUM_ITERATIONS
// IMPORT LIBRARIES
-const { DynamicPool, StaticPool } = require('node-worker-threads-pool')
+const { DynamicPool } = require('node-worker-threads-pool')
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
const functionToBench = require('./functions/function-to-bench')
--- /dev/null
+// IMPORT LIBRARIES
+const workerpool = require('workerpool')
+// FINISH IMPORT LIBRARIES
+const size = process.env.POOL_SIZE
+const iterations = process.env.NUM_ITERATIONS
+const dataArray = ['MYBENCH', process.env['TASK_TYPE']]
+
+const workerPool = workerpool.pool(
+ './workers/workerpool/function-to-bench-worker.js',
+ {
+ minWorkers: Number(size),
+ maxWorkers: size * 3,
+ workerType: 'thread'
+ }
+)
+
+async function run () {
+ const promises = []
+ for (let i = 0; i < iterations; i++) {
+ promises.push(workerPool.exec('functionToBench', dataArray))
+ }
+ await Promise.all(promises)
+ process.exit()
+}
+
+run()
// IMPORT LIBRARIES
-const { FixedThreadPool, DynamicThreadPool } = require('poolifier')
+const { FixedThreadPool } = require('poolifier')
// FINISH IMPORT LIBRARIES
const size = process.env.POOL_SIZE
const iterations = process.env.NUM_ITERATIONS
--- /dev/null
+// IMPORT LIBRARIES
+const workerpool = require('workerpool')
+// FINISH IMPORT LIBRARIES
+const size = process.env.POOL_SIZE
+const iterations = process.env.NUM_ITERATIONS
+const dataArray = ['MYBENCH', process.env['TASK_TYPE']]
+
+const workerPool = workerpool.pool(
+ './workers/workerpool/function-to-bench-worker.js',
+ {
+ minWorkers: Number(size),
+ maxWorkers: Number(size),
+ workerType: 'thread'
+ }
+)
+
+async function run () {
+ const promises = []
+ for (let i = 0; i < iterations; i++) {
+ promises.push(workerPool.exec('functionToBench', dataArray))
+ }
+ await Promise.all(promises)
+ process.exit()
+}
+
+run()
module.exports = function (data) {
if (data.taskType === 'CPU_INTENSIVE') {
- // CPU Intensive task
+ // CPU intensive task
for (let i = 0; i <= 5000; i++) {
const o = {
a: i
}
},
"workerpool": {
- "version": "6.1.0",
- "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz",
- "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg=="
+ "version": "6.1.2",
+ "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.2.tgz",
+ "integrity": "sha512-I/gDW4LwV3bslk4Yiqd4XoNYlnvV03LON7KuIjmQ90yDnKND1sR2LK/JA1g1tmd71oe6KPSvN0JpBzXIH6xAgA=="
},
"wrappy": {
"version": "1.0.2",
"threads": "1.6.3",
"threadwork": "0.6.0",
"worker-threads-pool": "2.0.0",
- "workerpool": "6.1.0"
+ "workerpool": "6.1.2"
}
}
// IMPORT LIBRARIES
-const { DynamicPool, StaticPool } = require('node-worker-threads-pool')
+const { StaticPool } = require('node-worker-threads-pool')
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
const functionToBench = require('./functions/function-to-bench')
--- /dev/null
+'use strict'
+const workerpool = require('workerpool')
+const functionToBench = require('../../functions/function-to-bench')
+
+function workerPoolWrapperFunctionToBench (testName, taskType) {
+ return functionToBench({ test: testName, taskType: taskType })
+}
+
+workerpool.worker({
+ functionToBench: workerPoolWrapperFunctionToBench
+})