X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fthread%2Ffixed.js;h=3f40f3fbcac920f9f4013bdb59d3c155fdb42b57;hb=719cb07a5270674b28f3a21d755524e90b01365e;hp=cd7fdebfdceeb57881be02299447ef3d3533f89d;hpb=292ad316a2815762f2e4a822383f1aef5ae49774;p=poolifier.git diff --git a/benchmarks/internal/thread/fixed.js b/benchmarks/internal/thread/fixed.js index cd7fdebf..3f40f3fb 100644 --- a/benchmarks/internal/thread/fixed.js +++ b/benchmarks/internal/thread/fixed.js @@ -2,9 +2,10 @@ const { FixedThreadPool, WorkerChoiceStrategies } = require('../../../lib/index') -const { runPoolifierTest } = require('../benchmark-utils') +const { runPoolifierTest } = require('../../benchmarks-utils') const size = 30 +const numberOfTasks = 1 const fixedPool = new FixedThreadPool( size, @@ -17,16 +18,45 @@ const fixedPoolLessRecentlyUsed = new FixedThreadPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +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 ( - { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { return runPoolifierTest(fixedPool, { tasks, workerData }) } async function fixedThreadTestLessRecentlyUsed ( - { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) } -module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed } +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, + fixedThreadTestLessRecentlyUsed, + fixedThreadTestWeightedRoundRobin, + fixedThreadTestFairShare +}