Move tasks scheduling implementation benchmark into its own directory
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 20 Oct 2022 21:15:21 +0000 (23:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 20 Oct 2022 21:15:21 +0000 (23:15 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
benchmarks/worker-selection/lru.js [moved from benchmarks/internal/quick-select.js with 100% similarity]
benchmarks/worker-selection/round-robin.js [moved from benchmarks/internal/choose-worker.js with 81% similarity]

similarity index 81%
rename from benchmarks/internal/choose-worker.js
rename to benchmarks/worker-selection/round-robin.js
index 64f36512d3d699e02e1e59745a429bf912c5a038..0e391a988674ec0fb0337acc87715de484b97f28 100644 (file)
@@ -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())