X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fthread%2Ffixed.js;h=c8be6feb17c3fe92a30602b58c3aaba8482f9bc3;hb=d49303bcd1dc86f36030dff08796f869681d4eae;hp=617aa7e5950952c241c2c98a091e2cf8965553b6;hpb=e843b9042b77e0e4e17c193820a3e05ffc92cffe;p=poolifier.git diff --git a/benchmarks/internal/thread/fixed.js b/benchmarks/internal/thread/fixed.js index 617aa7e5..c8be6feb 100644 --- a/benchmarks/internal/thread/fixed.js +++ b/benchmarks/internal/thread/fixed.js @@ -2,7 +2,7 @@ const { FixedThreadPool, WorkerChoiceStrategies } = require('../../../lib/index') -const { runPoolifierTest } = require('../benchmark-utils') +const { runPoolifierTest } = require('../../benchmarks-utils') const size = 30 const numberOfTasks = 1 @@ -12,10 +12,34 @@ const fixedPool = new FixedThreadPool( './benchmarks/internal/thread/worker.js' ) -const fixedPoolLessRecentlyUsed = new FixedThreadPool( +const fixedPoolTasksQueue = new FixedThreadPool( size, './benchmarks/internal/thread/worker.js', - { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } + { enableTasksQueue: true } +) + +const fixedPoolLessUsed = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED } +) + +const fixedPoolLessBusy = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY } +) + +const fixedPoolWeightedRoundRobin = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } +) + +const fixedPoolFairShare = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE } ) async function fixedThreadTest ( @@ -24,10 +48,41 @@ async function fixedThreadTest ( return runPoolifierTest(fixedPool, { tasks, workerData }) } -async function fixedThreadTestLessRecentlyUsed ( +async function fixedThreadTasksQueueTest ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { - return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) + return runPoolifierTest(fixedPoolTasksQueue, { tasks, workerData }) } -module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed } +async function fixedThreadTestLessUsed ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData }) +} + +async function fixedThreadTestLessBusy ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolLessBusy, { tasks, workerData }) +} + +async function fixedThreadTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData }) +} + +async function fixedThreadTestFairShare ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolFairShare, { tasks, workerData }) +} + +module.exports = { + fixedThreadTest, + fixedThreadTasksQueueTest, + fixedThreadTestLessUsed, + fixedThreadTestLessBusy, + fixedThreadTestWeightedRoundRobin, + fixedThreadTestFairShare +}