From 0d6f0c139094fec2aff96904c0e8cacbc37dfcf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 20 Oct 2022 23:15:21 +0200 Subject: [PATCH] Move tasks scheduling implementation benchmark into its own directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../quick-select.js => worker-selection/lru.js} | 0 .../round-robin.js} | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) rename benchmarks/{internal/quick-select.js => worker-selection/lru.js} (100%) rename benchmarks/{internal/choose-worker.js => worker-selection/round-robin.js} (81%) 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()) -- 2.34.1