X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=min.mjs;h=ebd22cde5e2fc4661b1f6fc39c4f27e792df9e3e;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=c7efed1a18402cbc9882dfba3c3a903da31402c5;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/min.mjs b/min.mjs index c7efed1..ebd22cd 100644 --- a/min.mjs +++ b/min.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 sortMin (values) { return values.sort((a, b) => a - b)[0] } -Benchmark.suite( - `Min from ${size} numbers`, - Benchmark.add('Math.min', () => { +group(`Min from ${size} numbers`, () => { + bench('Math.min', () => { Math.min(...testArray) - }), - Benchmark.add('loopMin', () => { + }) + bench('loopMin', () => { loopMin(testArray) - }), - Benchmark.add('reduceTernaryMin', () => { + }) + bench('reduceTernaryMin', () => { reduceTernaryMin(testArray) - }), - Benchmark.add('reduceMath.min', () => { + }) + bench('reduceMathMin', () => { reduceMathMin(testArray) - }), - Benchmark.add('sortMin', () => { + }) + bench('sortMin', () => { sortMin(testArray) - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'min', format: 'json', details: true }), - Benchmark.save({ file: 'min', format: 'chart.html', details: true }), - Benchmark.save({ file: 'min', format: 'table.html', details: true }) -).catch(console.error) + }) +}) + +await run({ + units: true +})