X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=empty-array.mjs;h=825088f1780c92429a7e6ad7308becfd21ac7471;hb=HEAD;hp=887e0ce183ecfcf956ea41245cb9aa188c4b5bb1;hpb=f522d7b906f8a45a7e4fd349abe3f83bf8fc3d69;p=benchmarks-js.git diff --git a/empty-array.mjs b/empty-array.mjs index 887e0ce..27cdca2 100644 --- a/empty-array.mjs +++ b/empty-array.mjs @@ -1,35 +1,32 @@ -import Benchmark from 'benny' -import { generateRandomNumberArray } from './benchmark-utils.js' +import { bench, group, run } from 'tatami-ng' + +import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 let testArray = generateRandomNumberArray(size) -Benchmark.suite( - `Empty array with ${size} elements`, - Benchmark.add('length = 0', () => { +group(`Empty array with ${size} elements`, () => { + bench('length = 0', () => { testArray.length = 0 - }), - Benchmark.add('pop loop', () => { + }) + bench('pop loop', () => { while (testArray.length > 0) { testArray.pop() } - }), - Benchmark.add('splice', () => { + }) + bench('splice', () => { testArray.splice(0, testArray.length) - }), - Benchmark.add('shift loop', () => { + }) + bench('shift loop', () => { while (testArray.length > 0) { testArray.shift() } - }), - Benchmark.add('new init', () => { + }) + bench('initialize', () => { testArray = [] - }), - Benchmark.cycle(), - Benchmark.complete(), - Benchmark.save({ file: 'empty-array', format: 'json', details: true }), - Benchmark.save({ file: 'empty-array', format: 'chart.html', details: true }), - Benchmark.save({ file: 'empty-array', format: 'table.html', details: true }) -).catch(err => { - console.error(err) + }) +}) + +await run({ + units: true, })