- 'Shinigami92'
- 'jerome-benoit'
versioning-strategy: increase
+ - package-ecosystem: 'npm'
+ directory: '/benchmarks/versus-external-pools'
+ schedule:
+ interval: 'daily'
+ labels:
+ - 'dependencies'
+ - 'benchmarks'
+ - 'nocombine'
+ reviewers:
+ - 'pioardi'
+ - 'Shinigami92'
+ - 'jerome-benoit'
+ versioning-strategy: increase
module.exports = {
'**/*.{js,mjs,ts}': ['eslint --cache --fix'],
'**/*.{json,md,yml}': [
- 'prettier --loglevel silent --write',
+ 'prettier --write',
'prettierx --write'
]
}
+const WorkerFunctions = {
+ jsonIntegerSerialization: 'jsonIntegerSerialization',
+ fibonacci: 'fibonacci',
+ factorial: 'factorial'
+}
+
async function runPoolifierTest (pool, { tasks, workerData }) {
return new Promise((resolve, reject) => {
let executions = 0
}
}
+function executeWorkerFunction (data) {
+ switch (data.function) {
+ case WorkerFunctions.jsonIntegerSerialization:
+ return jsonIntegerSerialization(data.n || 1000)
+ case WorkerFunctions.fibonacci:
+ return fibonacci(data.n || 50)
+ case WorkerFunctions.factorial:
+ return factorial(data.n || 1000)
+ default:
+ throw new Error('Unknown worker function')
+ }
+}
+
const LIST_FORMATTER = new Intl.ListFormat('en-US', {
style: 'long',
type: 'conjunction'
})
module.exports = {
- runPoolifierTest,
- jsonIntegerSerialization,
+ LIST_FORMATTER,
+ WorkerFunctions,
+ executeWorkerFunction,
generateRandomInteger,
- fibonacci,
- factorial,
- LIST_FORMATTER
+ runPoolifierTest
}
'use strict'
const { isMaster } = require('cluster')
const { ClusterWorker } = require('../../../lib/index')
-const { jsonIntegerSerialization } = require('../benchmark-utils')
+const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils')
const debug = false
function yourFunction (data) {
- jsonIntegerSerialization(1000)
+ data = data || {}
+ data.function = data.function || WorkerFunctions.jsonIntegerSerialization
+ executeWorkerFunction(data)
debug === true && console.debug('This is the main thread ' + isMaster)
return { ok: 1 }
}
'use strict'
const { isMainThread } = require('worker_threads')
const { ThreadWorker } = require('../../../lib/index')
-const { jsonIntegerSerialization } = require('../benchmark-utils')
+const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils')
const debug = false
function yourFunction (data) {
- jsonIntegerSerialization(1000)
+ data = data || {}
+ data.function = data.function || WorkerFunctions.jsonIntegerSerialization
+ executeWorkerFunction(data)
debug === true && console.debug('This is the main thread ' + isMainThread)
return { ok: 1 }
}
const { expect } = require('expect')
const { DynamicClusterPool } = require('../../../lib/index')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
const TestUtils = require('../../test-utils')
describe('Dynamic cluster pool test suite', () => {
const { expect } = require('expect')
const { FixedClusterPool } = require('../../../lib/index')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
const TestUtils = require('../../test-utils')
describe('Fixed cluster pool test suite', () => {
const { expect } = require('expect')
const { DynamicThreadPool } = require('../../../lib/index')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
const TestUtils = require('../../test-utils')
describe('Dynamic thread pool test suite', () => {
const { expect } = require('expect')
const { FixedThreadPool } = require('../../../lib/index')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
const TestUtils = require('../../test-utils')
describe('Fixed thread pool test suite', () => {
factorial: 'factorial'
}
-module.exports = WorkerFunctions
+module.exports = { WorkerFunctions }
-const WorkerFunctions = require('./test-types')
+const { WorkerFunctions } = require('./test-types')
class TestUtils {
static async waitExits (pool, numberOfExitEventsToWait) {
const { ClusterWorker, KillBehaviors } = require('../../../lib/index')
const { isMaster } = require('cluster')
const TestUtils = require('../../test-utils')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
function test (data) {
data = data || {}
const { ThreadWorker, KillBehaviors } = require('../../../lib/index')
const { isMainThread } = require('worker_threads')
const TestUtils = require('../../test-utils')
-const WorkerFunctions = require('../../test-types')
+const { WorkerFunctions } = require('../../test-types')
function test (data) {
data = data || {}