X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=max.mjs;h=23fcfdfb8762f65f91ef23d2a6cf3a9af21693fa;hb=c7d6615d759b56dc3ba10dcfadd51854929b2d30;hp=60fcdeac0764ba2016cd71050b94e27f228499f3;hpb=f913c68ce1ad111704f1f319706cb99e9659e236;p=benchmarks-js.git diff --git a/max.mjs b/max.mjs index 60fcdea..23fcfdf 100644 --- a/max.mjs +++ b/max.mjs @@ -1,4 +1,5 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'tatami-ng' + import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 @@ -47,28 +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(err => { - console.error(err) + }) +}) + +await run({ + units: true })