X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=empty-array.mjs;h=5a1e0818b329747abcfa9504c3089f7fe46af2e5;hb=ab9a08f3b8fdd43f8714e90652028621849f9f58;hp=f9bd2147325d45c86b5e31f25c39a2b5c9dd5a29;hpb=1b4e2f913afc4f5dfed823720d89dde05d23d184;p=benchmarks-js.git diff --git a/empty-array.mjs b/empty-array.mjs index f9bd214..5a1e081 100644 --- a/empty-array.mjs +++ b/empty-array.mjs @@ -1,34 +1,32 @@ -import Benchmark from 'benny' +import { bench, group, run } from 'mitata' 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(console.error) + }) +}) + +await run({ + units: true +})