The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [2.0.x] - yyyy-dd-mm
+
+### Bug fixes
+
+- Check if pool options are properly set.
+- `busy` event is emitted on all pool types.
+
## [2.0.0] - 2021-01-03
### Bug fixes
### Breaking Changes
-- `FullPool` event is now renamed to `busy` and emitted on all pool types.
+- `FullPool` event is now renamed to `busy`.
- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
_Find more details on our JSDoc._
- [piscina](https://github.com/piscinajs/piscina)
- [SUCHMOKUO/node-worker-threads-pool](https://github.com/SUCHMOKUO/node-worker-threads-pool)
- [threads.js](https://github.com/andywer/threads.js/)
+- [workerpool](https://github.com/josdejong/workerpool)
+- [threadwork](https://github.com/kevlened/threadwork)
+- [microjob](https://github.com/wilk/microjob)
Those are our results:
'node static-suchmokuo-node-worker-threads-pool.js' \
'node threadjs.js' \
'node dynamic-workerpool.js' \
- 'node fixed-workerpool.js'
+ 'node fixed-workerpool.js' \
+ 'node fixed-threadwork.js' \
+ 'node fixed-microjob.js'
--- /dev/null
+// IMPORT LIBRARIES
+const { job, start } = require('microjob')
+// FINISH IMPORT LIBRARIES
+// IMPORT FUNCTION TO BENCH
+const functionToBench = require('./functions/function-to-bench')
+// FINISH IMPORT FUNCTION TO BENCH
+const size = process.env.POOL_SIZE
+const iterations = process.env.NUM_ITERATIONS
+const data = {
+ test: 'MYBENCH',
+ taskType: process.env['TASK_TYPE']
+}
+
+async function run () {
+ await start({ maxWorkers: Number(size) })
+ const promises = []
+ for (let i = 0; i < iterations; i++) {
+ promises.push(
+ job(
+ data => {
+ functionToBench(data)
+ },
+ { data: data, ctx: { functionToBench } }
+ )
+ )
+ }
+ await Promise.all(promises)
+ process.exit()
+}
+
+run()
--- /dev/null
+// IMPORT LIBRARIES
+const { ThreadPool } = require('threadwork')
+// FINISH IMPORT LIBRARIES
+// IMPORT FUNCTION TO BENCH
+const functionToBench = require('./functions/function-to-bench')
+// FINISH IMPORT FUNCTION TO BENCH
+const size = process.env.POOL_SIZE
+const iterations = process.env.NUM_ITERATIONS
+const data = {
+ test: 'MYBENCH',
+ taskType: process.env['TASK_TYPE']
+}
+
+const threadPool = new ThreadPool({ task: functionToBench, size: size })
+
+async function run () {
+ const promises = []
+ for (let i = 0; i < iterations; i++) {
+ promises.push(threadPool.run(data))
+ }
+ await Promise.all(promises)
+ process.exit()
+}
+
+run()