--- /dev/null
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+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).
+
+## [1.0.0] - 2020-24-01
+
+### Added
+
+- FixedThreadPool implementation
+- DynamicThreadPool implementation
+- WorkerThread implementation to improve developer experience
\ No newline at end of file
const suite = new Benchmark.Suite()
const FixedThreadPool = require('../lib/fixed')
const DynamicThreadPool = require('../lib/dynamic')
-const Pool = require('worker-threads-pool')
const size = 30
const tasks = 1
// pools
-const externalPool = new Pool({ max: size })
const fixedPool = new FixedThreadPool(size,
'./yourWorker.js', { maxTasks: 10000 })
const dynamicPool = new DynamicThreadPool(size / 2, size * 3, './yourWorker.js', { maxTasks: 10000 })
})
}
-async function externalPoolTest () {
- return new Promise((resolve, reject) => {
- let executions = 0
- for (let i = 0; i <= tasks; i++) {
- new Promise((resolve, reject) => {
- externalPool.acquire('./externalWorker.js', { workerData: workerData }, (err, worker) => {
- if (err) {
- return reject(err)
- }
- worker.on('error', reject)
- worker.on('message', res => {
- executions++
- resolve(res)
- })
- })
- }).then(res => {
- if (tasks === executions) {
- resolve('FINISH')
- }
- })
- }
- })
-}
-
async function test () {
// add tests
suite.add('PioardiStaticPool', async function () {
.add('PioardiDynamicPool', async function () {
await dynamicTest()
})
- .add('ExternalPool', async function () {
- await externalPoolTest()
- })
// add listeners
.on('cycle', function (event) {
console.log(String(event.target))