X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fworker-selection%2Fround-robin.js;h=0b8b9ec23de9d3d49c753e4aa81914d0940fa84b;hb=719cb07a5270674b28f3a21d755524e90b01365e;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..0b8b9ec2 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( + 'Less recently used', + 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() +)