X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fworker-selection%2Fround-robin.mjs;h=828924503c8890d597d43bdd44692fa2c3c0d16a;hb=ecde6ea8c439bbdd9dc2ca118731b5006a1a9884;hp=483098d2ff93d0a4c0bb9b225b11ccbe963e6bd2;hpb=5972baf82c740050a6da461a8deb8497fcaa8580;p=poolifier.git diff --git a/benchmarks/worker-selection/round-robin.mjs b/benchmarks/worker-selection/round-robin.mjs index 483098d2..82892450 100644 --- a/benchmarks/worker-selection/round-robin.mjs +++ b/benchmarks/worker-selection/round-robin.mjs @@ -1,5 +1,4 @@ -import Benchmark from 'benchmark' -import { LIST_FORMATTER } from '../benchmarks-utils.mjs' +import { bench, group, run } from 'tatami-ng' function generateWorkersArray (numberOfWorkers) { return [...Array(numberOfWorkers).keys()] @@ -37,29 +36,23 @@ function roundRobinIncrementModulo () { return chosenWorker } -new Benchmark.Suite('Round robin tasks distribution') - .add('Ternary off by one', () => { +group('Round robin tasks distribution', () => { + bench('Ternary off by one', () => { nextWorkerIndex = 0 roundRobinTernaryOffByOne() }) - .add('Ternary with negation', () => { + bench('Ternary with negation', () => { nextWorkerIndex = 0 roundRobinTernaryWithNegation() }) - .add('Ternary with pre-choosing', () => { + bench('Ternary with pre-choosing', () => { nextWorkerIndex = 0 roundRobinTernaryWithPreChoosing() }) - .add('Increment+Modulo', () => { + bench('Increment+Modulo', () => { nextWorkerIndex = 0 roundRobinIncrementModulo() }) - .on('cycle', event => { - console.info(event.target.toString()) - }) - .on('complete', function () { - console.info( - 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name')) - ) - }) - .run() +}) + +await run({ units: true })