1 import Benchmark from 'benny'
3 import { generateRandomNumberArray } from './benchmark-utils.mjs'
6 let testArray = generateRandomNumberArray(size)
9 `Empty array with ${size} elements`,
10 Benchmark.add('length = 0', () => {
13 Benchmark.add('pop loop', () => {
14 while (testArray.length > 0) {
18 Benchmark.add('splice', () => {
19 testArray.splice(0, testArray.length)
21 Benchmark.add('shift loop', () => {
22 while (testArray.length > 0) {
26 Benchmark.add('new init', () => {
31 Benchmark.save({ file: 'empty-array', format: 'json', details: true }),
32 Benchmark.save({ file: 'empty-array', format: 'chart.html', details: true }),
33 Benchmark.save({ file: 'empty-array', format: 'table.html', details: true })
34 ).catch(console.error)