X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fworker-selection%2Fleast.mjs;h=4be3826f7e8165bb698e9c9dd21617b8b0f26160;hb=1c2836752370268903fa3f1d21c95f0e8f6fee12;hp=f67bebf7464f5ff7cadc394d38279bfc76e804bc;hpb=c7ed5d3b88f8f2c75675d953a4e9df87a3d9a54c;p=poolifier.git diff --git a/benchmarks/worker-selection/least.mjs b/benchmarks/worker-selection/least.mjs index f67bebf7..4be3826f 100644 --- a/benchmarks/worker-selection/least.mjs +++ b/benchmarks/worker-selection/least.mjs @@ -1,6 +1,6 @@ import { randomInt } from 'node:crypto' -import Benchmark from 'benchmark' -import { LIST_FORMATTER } from '../benchmarks-utils.cjs' + +import { bench, group, run } from 'tatami-ng' function generateRandomTasksMap ( numberOfWorkers, @@ -18,7 +18,7 @@ const tasksMap = generateRandomTasksMap(60, 20) function loopSelect (tasksMap) { let minKey - let minValue = Infinity + let minValue = Number.POSITIVE_INFINITY for (const [key, value] of tasksMap) { if (value === 0) { return key @@ -168,31 +168,25 @@ function quickSelectRecursionRandomPivot (tasksMap) { ) } -new Benchmark.Suite('Least used worker tasks distribution') - .add('Loop select', () => { +group('Least used worker tasks distribution', () => { + bench('Loop select', () => { loopSelect(tasksMap) }) - .add('Array sort select', () => { + bench('Array sort select', () => { arraySortSelect(tasksMap) }) - .add('Quick select loop', () => { + bench('Quick select loop', () => { quickSelectLoop(tasksMap) }) - .add('Quick select loop with random pivot', () => { + bench('Quick select loop with random pivot', () => { quickSelectLoopRandomPivot(tasksMap) }) - .add('Quick select recursion', () => { + bench('Quick select recursion', () => { quickSelectRecursion(tasksMap) }) - .add('Quick select recursion with random pivot', () => { + bench('Quick select recursion with random pivot', () => { quickSelectRecursionRandomPivot(tasksMap) }) - .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 })