X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fworker-selection%2Fround-robin.mjs;h=d39fd699f58016e69052f52dbcf87e6945c5f07b;hb=4a537a1a729bd3c5fb7eaccb0a6cafa4f660f26b;hp=828924503c8890d597d43bdd44692fa2c3c0d16a;hpb=98f60ddd83d32e108adcfddebeb902f0d5a197eb;p=poolifier.git diff --git a/benchmarks/worker-selection/round-robin.mjs b/benchmarks/worker-selection/round-robin.mjs index 82892450..d39fd699 100644 --- a/benchmarks/worker-selection/round-robin.mjs +++ b/benchmarks/worker-selection/round-robin.mjs @@ -1,5 +1,9 @@ import { bench, group, run } from 'tatami-ng' +/** + * + * @param numberOfWorkers + */ function generateWorkersArray (numberOfWorkers) { return [...Array(numberOfWorkers).keys()] } @@ -8,12 +12,18 @@ const workers = generateWorkersArray(60) let nextWorkerIndex +/** + * + */ function roundRobinTernaryOffByOne () { nextWorkerIndex = workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1 return workers[nextWorkerIndex] } +/** + * + */ function roundRobinTernaryWithNegation () { nextWorkerIndex = !nextWorkerIndex || workers.length - 1 === nextWorkerIndex @@ -22,6 +32,9 @@ function roundRobinTernaryWithNegation () { return workers[nextWorkerIndex] } +/** + * + */ function roundRobinTernaryWithPreChoosing () { const chosenWorker = workers[nextWorkerIndex] nextWorkerIndex = @@ -29,6 +42,9 @@ function roundRobinTernaryWithPreChoosing () { return chosenWorker } +/** + * + */ function roundRobinIncrementModulo () { const chosenWorker = workers[nextWorkerIndex] nextWorkerIndex++