build(deps-dev): apply updates
[benchmarks-js.git] / empty-array.mjs
1 import Benchmark from 'benny'
2
3 import { generateRandomNumberArray } from './benchmark-utils.mjs'
4
5 const size = 10000
6 let testArray = generateRandomNumberArray(size)
7
8 Benchmark.suite(
9 `Empty array with ${size} elements`,
10 Benchmark.add('length = 0', () => {
11 testArray.length = 0
12 }),
13 Benchmark.add('pop loop', () => {
14 while (testArray.length > 0) {
15 testArray.pop()
16 }
17 }),
18 Benchmark.add('splice', () => {
19 testArray.splice(0, testArray.length)
20 }),
21 Benchmark.add('shift loop', () => {
22 while (testArray.length > 0) {
23 testArray.shift()
24 }
25 }),
26 Benchmark.add('new init', () => {
27 testArray = []
28 }),
29 Benchmark.cycle(),
30 Benchmark.complete(),
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)