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