- [tinypool](https://github.com/tinylibs/tinypool)
- [workerpool](https://github.com/josdejong/workerpool)
- [worker-nodes](https://github.com/allegro/node-worker-nodes)
+- [node-worker-threads-pool](https://github.com/SUCHMOKUO/node-worker-threads-pool)
- [threads.js](https://github.com/andywer/threads.js/)
- [threadwork](https://github.com/kevlened/threadwork)
- [microjob](https://github.com/wilk/microjob)
External pools with which we used to compare the poolifier results:
-- [node-worker-threads-pool](https://github.com/SUCHMOKUO/node-worker-threads-pool): removed because it does not support dynamic modules import or import outside the worker function. The worker function is expected to be self-contained, which makes it difficult to use in real world application without ugly hacks.
+<!-- - [node-worker-threads-pool](https://github.com/SUCHMOKUO/node-worker-threads-pool): removed because it does not support dynamic modules import or import outside the worker function. The worker function is expected to be self-contained, which makes it difficult to use in real world application without ugly hacks. -->
+
- [worker-threads-pool](https://github.com/watson/worker-threads-pool): removed because unmaintained since more than 4 years.
### Internal
import { DynamicPool } from 'node-worker-threads-pool'
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
-import functionToBench from './functions/function-to-bench.mjs'
+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)
// IMPORT LIBRARIES
-import WorkerNodes from 'worker-nodes'
+const WorkerNodes = require('worker-nodes')
// FINISH IMPORT LIBRARIES
const size = parseInt(process.env.POOL_SIZE)
const iterations = parseInt(process.env.NUM_ITERATIONS)
}
const workerNodes = new WorkerNodes(
- import.meta.resolve('./workers/worker-nodes/function-to-bench-worker'),
+ require.resolve('./workers/worker-nodes/function-to-bench-worker'),
{
minWorkers: size,
maxWorkers: size * 3,
process.exit()
}
-await run()
+(async () => {
+ try {
+ await run()
+ } catch (e) {
+ console.error(e)
+ // eslint-disable-next-line n/no-process-exit
+ process.exit(1)
+ }
+})()
import { job, start } from 'microjob'
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
-import functionToBench from './functions/function-to-bench.mjs'
+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)
// IMPORT LIBRARIES
-import WorkerNodes from 'worker-nodes'
+const WorkerNodes = require('worker-nodes')
// FINISH IMPORT LIBRARIES
const size = parseInt(process.env.POOL_SIZE)
const iterations = parseInt(process.env.NUM_ITERATIONS)
}
const workerNodes = new WorkerNodes(
- import.meta.resolve('./workers/worker-nodes/function-to-bench-worker'),
+ require.resolve('./workers/worker-nodes/function-to-bench-worker'),
{
minWorkers: size,
maxWorkers: size,
process.exit()
}
-await run()
+(async () => {
+ try {
+ await run()
+ } catch (e) {
+ console.error(e)
+ // eslint-disable-next-line n/no-process-exit
+ process.exit(1)
+ }
+})()
-import crypto from 'crypto'
-import fs from 'fs'
-
/**
* The worker function to execute during pools benchmarks.
* NOTE: This function requires to be self-contained, thread-safe and re-entrant.
* @param {*} data The worker data.
* @returns {*} The result.
*/
-export default function functionToBench (data) {
+module.exports = function functionToBench (data) {
+ const crypto = require('crypto')
+ const fs = require('fs')
const TaskTypes = {
CPU_INTENSIVE: 'CPU_INTENSIVE',
IO_INTENSIVE: 'IO_INTENSIVE'
'node dynamic-tinypool.mjs' \
'node dynamic-workerpool.mjs' \
'node fixed-workerpool.mjs' \
- 'node --experimental-import-meta-resolve dynamic-worker-nodes.mjs' \
- 'node --experimental-import-meta-resolve fixed-worker-nodes.mjs' \
+ 'node dynamic-worker-nodes.js' \
+ 'node fixed-worker-nodes.js' \
+ 'node dynamic-node-worker-threads-pool.mjs' \
+ 'node static-node-worker-threads-pool.mjs' \
'node threadjs.mjs' \
'node fixed-threadwork.mjs' \
'node fixed-microjob.mjs'
import { ThreadPool } from 'threadwork'
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
-import functionToBench from './functions/function-to-bench.mjs'
+import functionToBench from './functions/function-to-bench.js'
// FINISH IMPORT FUNCTION TO BENCH
const size = parseInt(process.env.POOL_SIZE)
import { StaticPool } from 'node-worker-threads-pool'
// FINISH IMPORT LIBRARIES
// IMPORT FUNCTION TO BENCH
-import functionToBench from './functions/function-to-bench.mjs'
+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)
-import functionToBench from '../../functions/function-to-bench.mjs'
+import functionToBench from '../../functions/function-to-bench.js'
export default functionToBench
import { ThreadWorker } from 'poolifier'
-import functionToBench from '../../functions/function-to-bench.mjs'
+import functionToBench from '../../functions/function-to-bench.js'
export default new ThreadWorker(functionToBench)
import { expose } from 'threads/worker'
-import functionToBench from '../../functions/function-to-bench.mjs'
+import functionToBench from '../../functions/function-to-bench.js'
expose({
exposedFunction (data) {
-import functionToBench from '../../functions/function-to-bench.mjs'
+import functionToBench from '../../functions/function-to-bench.js'
export default functionToBench
--- /dev/null
+const functionToBench = require('../../functions/function-to-bench')
+module.exports = functionToBench
+++ /dev/null
-import functionToBench from '../../functions/function-to-bench.mjs'
-export { functionToBench }
import workerpool from 'workerpool'
-import functionToBench from '../../functions/function-to-bench.mjs'
+import functionToBench from '../../functions/function-to-bench.js'
function wrapperFunctionToBench (testName, taskType, taskSize) {
return functionToBench({