function executeWorkerFunction (data) {
switch (data.function) {
case WorkerFunctions.jsonIntegerSerialization:
- return jsonIntegerSerialization(data.n || 1000)
+ return jsonIntegerSerialization(data.taskSize || 1000)
case WorkerFunctions.fibonacci:
- return fibonacci(data.n || 1000)
+ return fibonacci(data.taskSize || 1000)
case WorkerFunctions.factorial:
- return factorial(data.n || 1000)
+ return factorial(data.taskSize || 1000)
default:
throw new Error('Unknown worker function')
}
fixedThreadTestLessRecentlyUsed,
fixedThreadTestWeightedRoundRobin
} = require('./thread/fixed')
-const { LIST_FORMATTER } = require('./benchmark-utils')
+const { LIST_FORMATTER } = require('../benchmarks-utils')
const suite = new Benchmark.Suite('poolifier')
const Benchmark = require('benchmark')
-const { LIST_FORMATTER } = require('./benchmark-utils')
+const { LIST_FORMATTER } = require('../benchmarks-utils')
const suite = new Benchmark.Suite()
DynamicClusterPool,
WorkerChoiceStrategies
} = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
const size = 30
const numberOfTasks = 1
FixedClusterPool,
WorkerChoiceStrategies
} = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
const size = 30
const numberOfTasks = 1
'use strict'
const { isMaster } = require('cluster')
const { ClusterWorker } = require('../../../lib/index')
-const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils')
+const {
+ WorkerFunctions,
+ executeWorkerFunction
+} = require('../../benchmarks-utils')
const debug = false
const Benchmark = require('benchmark')
-const { generateRandomInteger, LIST_FORMATTER } = require('./benchmark-utils')
+const { generateRandomInteger, LIST_FORMATTER } = require('../benchmarks-utils')
const suite = new Benchmark.Suite()
DynamicThreadPool,
WorkerChoiceStrategies
} = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
const size = 30
const numberOfTasks = 1
FixedThreadPool,
WorkerChoiceStrategies
} = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
const size = 30
const numberOfTasks = 1
'use strict'
const { isMainThread } = require('worker_threads')
const { ThreadWorker } = require('../../../lib/index')
-const { WorkerFunctions, executeWorkerFunction } = require('../benchmark-utils')
+const {
+ WorkerFunctions,
+ executeWorkerFunction
+} = require('../../benchmarks-utils')
const debug = false
const fs = require('fs')
+const {
+ WorkerFunctions,
+ executeWorkerFunction
+ // eslint-disable-next-line node/no-unpublished-require
+} = require('../../benchmarks-utils')
const TaskTypes = {
CPU_INTENSIVE: 'CPU_INTENSIVE',
switch (data.taskType) {
case TaskTypes.CPU_INTENSIVE:
// CPU intensive task
- for (let i = 0; i < data.taskSize; i++) {
- const o = {
- a: i
- }
- JSON.stringify(o)
- }
+ data.function = data.function || WorkerFunctions.jsonIntegerSerialization
+ executeWorkerFunction(data)
return { ok: 1 }
case TaskTypes.IO_INTENSIVE:
// IO intensive task