From: Jérôme Benoit Date: Thu, 20 Oct 2022 21:15:21 +0000 (+0200) Subject: Move tasks scheduling implementation benchmark into its own directory X-Git-Tag: v2.3.5~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0d6f0c139094fec2aff96904c0e8cacbc37dfcf7;p=poolifier.git Move tasks scheduling implementation benchmark into its own directory Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/internal/quick-select.js b/benchmarks/worker-selection/lru.js similarity index 100% rename from benchmarks/internal/quick-select.js rename to benchmarks/worker-selection/lru.js diff --git a/benchmarks/internal/choose-worker.js b/benchmarks/worker-selection/round-robin.js similarity index 81% rename from benchmarks/internal/choose-worker.js rename to benchmarks/worker-selection/round-robin.js index 64f36512..0e391a98 100644 --- a/benchmarks/internal/choose-worker.js +++ b/benchmarks/worker-selection/round-robin.js @@ -11,13 +11,13 @@ const workers = generateWorkersArray(60) let nextWorkerIndex -function chooseWorkerTernaryOffByOne () { +function roundRobinTernaryOffByOne () { nextWorkerIndex = workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1 return workers[nextWorkerIndex] } -function chooseWorkerTernaryWithNegation () { +function roundRobinTernaryWithNegation () { nextWorkerIndex = !nextWorkerIndex || workers.length - 1 === nextWorkerIndex ? 0 @@ -25,14 +25,14 @@ function chooseWorkerTernaryWithNegation () { return workers[nextWorkerIndex] } -function chooseWorkerTernaryWithPreChoosing () { +function roundRobinTernaryWithPreChoosing () { const chosenWorker = workers[nextWorkerIndex] nextWorkerIndex = workers.length - 1 === nextWorkerIndex ? 0 : nextWorkerIndex + 1 return chosenWorker } -function chooseWorkerIncrementModulo () { +function roundRobinIncrementModulo () { const chosenWorker = workers[nextWorkerIndex] nextWorkerIndex++ nextWorkerIndex %= workers.length @@ -42,19 +42,19 @@ function chooseWorkerIncrementModulo () { suite .add('Ternary off by one', function () { nextWorkerIndex = 0 - chooseWorkerTernaryOffByOne() + roundRobinTernaryOffByOne() }) .add('Ternary with negation', function () { nextWorkerIndex = 0 - chooseWorkerTernaryWithNegation() + roundRobinTernaryWithNegation() }) .add('Ternary with pre-choosing', function () { nextWorkerIndex = 0 - chooseWorkerTernaryWithPreChoosing() + roundRobinTernaryWithPreChoosing() }) .add('Increment+Modulo', function () { nextWorkerIndex = 0 - chooseWorkerIncrementModulo() + roundRobinIncrementModulo() }) .on('cycle', function (event) { console.log(event.target.toString())