X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=empty-array.js;h=c900a4239e4e4a04f17a5b92e3cadebb5d91377c;hb=5c3f3b95a1eee86af8c4fad058946d5a3275743a;hp=9ddc17d45b06d37b57c77129d0d1ed7b69620480;hpb=ed40d2b012a740d121f1951b9be91df341d6eaf3;p=benchmarks-js.git diff --git a/empty-array.js b/empty-array.js index 9ddc17d..c900a42 100644 --- a/empty-array.js +++ b/empty-array.js @@ -1,19 +1,20 @@ const Benchmark = require('benny') -const { generateRandomIntegerArray } = require('./benchmark-utils') +const { generateRandomNumberArray } = require('./benchmark-utils') -let testArray = generateRandomIntegerArray(10000) +const size = 10000 +let testArray = generateRandomNumberArray(size) Benchmark.suite( - 'Empty array', + `Empty array with ${size} elements`, Benchmark.add('length = 0', () => { testArray.length = 0 }), - Benchmark.add('pop loop', async () => { + Benchmark.add('pop loop', () => { while (testArray.length > 0) { testArray.pop() } }), - Benchmark.add('splice', async () => { + Benchmark.add('splice', () => { testArray.splice(0, testArray.length) }), Benchmark.add('shift loop', () => { @@ -26,6 +27,9 @@ Benchmark.suite( }), Benchmark.cycle(), Benchmark.complete(), - Benchmark.save({ file: 'empty-array', format: 'chart.html' }), - Benchmark.save({ file: 'empty-array', format: 'table.html' }) -) + 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) +})