1 const Benchmark
= require('benny')
2 const { generateRandomNumberArray
} = require('./benchmark-utils')
5 let testArray
= generateRandomNumberArray(size
)
8 `Empty array with ${size} elements`,
9 Benchmark
.add('length = 0', () => {
12 Benchmark
.add('pop loop', () => {
13 while (testArray
.length
> 0) {
17 Benchmark
.add('splice', () => {
18 testArray
.splice(0, testArray
.length
)
20 Benchmark
.add('shift loop', () => {
21 while (testArray
.length
> 0) {
25 Benchmark
.add('new init', () => {
30 Benchmark
.save({ file
: 'empty-array', format
: 'json', details
: true }),
31 Benchmark
.save({ file
: 'empty-array', format
: 'chart.html', details
: true }),
32 Benchmark
.save({ file
: 'empty-array', format
: 'table.html', details
: true })