X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=empty-array.js;h=a6a8acd84daa66c81fcdc5fa93c93d76e60841e2;hb=47006ddf6055b02dd084ae91269f12b44ce8225d;hp=e623b5ea88a66ff6ad8a6cfc214d83b81ac4cd9a;hpb=8e5cf49deec2da334e41f116efbe2623ea25245a;p=benchmarks-js.git diff --git a/empty-array.js b/empty-array.js index e623b5e..a6a8acd 100644 --- a/empty-array.js +++ b/empty-array.js @@ -1,31 +1,19 @@ const Benchmark = require('benny') +const { generateRandomNumberArray } = require('./benchmark-utils') -let testArray = [ - 83, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, - 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, - 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, - 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, - 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, - 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, - 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, - 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, - 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, - 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, - 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, - 36, 28 -] +let testArray = generateRandomNumberArray(10000) Benchmark.suite( 'Empty array', 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', () => { @@ -38,6 +26,7 @@ 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 }) )