X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=quick-select.mjs;h=49dc7057b5c70d30ad5894169cabfd02df409516;hb=HEAD;hp=d4270268fc58e25763684dff27533d643fbfdcdb;hpb=1ccd07249dcfce8874ff9433ce4dfb4b597b1bd3;p=benchmarks-js.git diff --git a/quick-select.mjs b/quick-select.mjs index d427026..5fc3ef3 100644 --- a/quick-select.mjs +++ b/quick-select.mjs @@ -1,5 +1,6 @@ import { randomInt } from 'node:crypto' -import Benchmark from 'benny' + +import { bench, group, run } from 'tatami-ng' /** * @param numberOfWorkers @@ -26,7 +27,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 @@ -227,41 +228,27 @@ function quickSelectRecursionRandomPivot (tasksMap) { ) } -Benchmark.suite( - 'Quick select', - Benchmark.add('Loop select', () => { +group('Quick select', () => { + bench('Loop select', () => { loopSelect(tasksMap) - }), - Benchmark.add('Array sort select', () => { + }) + bench('Array sort select', () => { arraySortSelect(tasksMap) - }), - Benchmark.add('Quick select loop', () => { + }) + bench('Quick select loop', () => { quickSelectLoop(tasksMap) - }), - Benchmark.add('Quick select loop with random pivot', () => { + }) + bench('Quick select loop with random pivot', () => { quickSelectLoopRandomPivot(tasksMap) - }), - Benchmark.add('Quick select recursion', () => { + }) + bench('Quick select recursion', () => { quickSelectRecursion(tasksMap) - }), - Benchmark.add('Quick select recursion with random pivot', () => { + }) + bench('Quick select recursion with random pivot', () => { quickSelectRecursionRandomPivot(tasksMap) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ - file: 'quick-select', - format: 'json', - details: true - }), - Benchmark.save({ - file: 'quick-select', - format: 'chart.html', - details: true - }), - Benchmark.save({ - file: 'quick-select', - format: 'table.html', - details: true }) -).catch(console.error) +}) + +await run({ + units: true, +})