X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=benchmarks%2Fworker-selection%2Flru.js;h=80d78893061e5d943eb467736759cc4adbc76ce5;hb=16c6355271e3dbe1f3d1b5b403901a04d923f021;hp=e60c84154f946da340ed27b98ca4e78274ca2d2c;hpb=0d6f0c139094fec2aff96904c0e8cacbc37dfcf7;p=poolifier.git diff --git a/benchmarks/worker-selection/lru.js b/benchmarks/worker-selection/lru.js index e60c8415..80d78893 100644 --- a/benchmarks/worker-selection/lru.js +++ b/benchmarks/worker-selection/lru.js @@ -1,7 +1,5 @@ -const Benchmark = require('benchmark') -const { generateRandomInteger, LIST_FORMATTER } = require('../benchmarks-utils') - -const suite = new Benchmark.Suite() +const Benchmark = require('benny') +const { generateRandomInteger } = require('../benchmarks-utils') function generateRandomTasksMap ( numberOfWorkers, @@ -52,7 +50,7 @@ const defaultPivotIndexSelect = (leftIndex, rightIndex) => { } const randomPivotIndexSelect = (leftIndex, rightIndex) => { - return generateRandomInteger(leftIndex, rightIndex) + return generateRandomInteger(rightIndex, leftIndex) } function swap (array, index1, index2) { @@ -169,41 +167,26 @@ function quickSelectRecursionRandomPivot (tasksMap) { ) } -// console.log(Array.from(tasksMap)) -// console.log(loopSelect(tasksMap)) -// console.log(arraySortSelect(tasksMap)) -// console.log(quickSelectLoop(tasksMap)) -// console.log(quickSelectLoopRandomPivot(tasksMap)) -// console.log(quickSelectRecursion(tasksMap)) -// console.log(quickSelectRecursionRandomPivot(tasksMap)) - -suite - .add('Loop select', function () { +Benchmark.suite( + 'Less used worker tasks distribution', + Benchmark.add('Loop select', () => { loopSelect(tasksMap) - }) - .add('Array sort select', function () { + }), + Benchmark.add('Array sort select', () => { arraySortSelect(tasksMap) - }) - .add('Quick select loop', function () { + }), + Benchmark.add('Quick select loop', () => { quickSelectLoop(tasksMap) - }) - .add('Quick select loop with random pivot', function () { + }), + Benchmark.add('Quick select loop with random pivot', () => { quickSelectLoopRandomPivot(tasksMap) - }) - .add('Quick select recursion', function () { + }), + Benchmark.add('Quick select recursion', () => { quickSelectRecursion(tasksMap) - }) - .add('Quick select recursion with random pivot', function () { + }), + Benchmark.add('Quick select recursion with random pivot', () => { quickSelectRecursionRandomPivot(tasksMap) - }) - .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() +)