X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=max.mjs;h=778c0efb7ad87d27c8031275ed572cde2e8d2cdc;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=2708eb0f51cbfb77bd43a10fde5667bea79e0ac6;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/max.mjs b/max.mjs index 2708eb0..778c0ef 100644 --- a/max.mjs +++ b/max.mjs @@ -1,4 +1,4 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' import { generateRandomNumberArray } from './benchmark-utils.mjs' @@ -48,26 +48,24 @@ function sortMax (values) { return values.sort((a, b) => b - a)[0] } -Benchmark.suite( - `Max from ${size} numbers`, - Benchmark.add('Math.max', () => { +group(`Max from ${size} numbers`, () => { + bench('Math.max', () => { Math.max(...testArray) - }), - Benchmark.add('loopMax', () => { + }) + bench('loopMax', () => { loopMax(testArray) - }), - Benchmark.add('reduceTernaryMax', () => { + }) + bench('reduceTernaryMax', () => { reduceTernaryMax(testArray) - }), - Benchmark.add('reduceMath.max', () => { + }) + bench('reduceMathMax', () => { reduceMathMax(testArray) - }), - Benchmark.add('sortMax', () => { + }) + bench('sortMax', () => { sortMax(testArray) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'max', format: 'json', details: true }), - Benchmark.save({ file: 'max', format: 'chart.html', details: true }), - Benchmark.save({ file: 'max', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +})