X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fworker-selection%2Fround-robin.js;h=67d3a365e7e9f96394e46a970d97cced6689a2a0;hb=c7c046988e2b4d93ce7998ebf39e5ad5ab92fec1;hp=0e391a988674ec0fb0337acc87715de484b97f28;hpb=0d6f0c139094fec2aff96904c0e8cacbc37dfcf7;p=poolifier.git diff --git a/benchmarks/worker-selection/round-robin.js b/benchmarks/worker-selection/round-robin.js index 0e391a98..67d3a365 100644 --- a/benchmarks/worker-selection/round-robin.js +++ b/benchmarks/worker-selection/round-robin.js @@ -1,7 +1,4 @@ -const Benchmark = require('benchmark') -const { LIST_FORMATTER } = require('../benchmarks-utils') - -const suite = new Benchmark.Suite() +const Benchmark = require('benny') function generateWorkersArray (numberOfWorkers) { return [...Array(numberOfWorkers).keys()] @@ -39,31 +36,24 @@ function roundRobinIncrementModulo () { return chosenWorker } -suite - .add('Ternary off by one', function () { +Benchmark.suite( + 'Round robin tasks distribution', + Benchmark.add('Ternary off by one', () => { nextWorkerIndex = 0 roundRobinTernaryOffByOne() - }) - .add('Ternary with negation', function () { + }), + Benchmark.add('Ternary with negation', () => { nextWorkerIndex = 0 roundRobinTernaryWithNegation() - }) - .add('Ternary with pre-choosing', function () { + }), + Benchmark.add('Ternary with pre-choosing', () => { nextWorkerIndex = 0 roundRobinTernaryWithPreChoosing() - }) - .add('Increment+Modulo', function () { + }), + Benchmark.add('Increment+Modulo', () => { nextWorkerIndex = 0 roundRobinIncrementModulo() - }) - .on('cycle', function (event) { - console.log(event.target.toString()) - }) - .on('complete', function () { - console.log( - 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name')) - ) - // eslint-disable-next-line n/no-process-exit - process.exit() - }) - .run() + }), + Benchmark.cycle(), + Benchmark.complete() +)