chore: configure vscode eslint for flat config
[benchmarks-js.git] / empty-array.mjs
1 import { bench, group, run } from 'tatami-ng'
2
3 import { generateRandomNumberArray } from './benchmark-utils.mjs'
4
5 const size = 10000
6 let testArray = generateRandomNumberArray(size)
7
8 group(`Empty array with ${size} elements`, () => {
9 bench('length = 0', () => {
10 testArray.length = 0
11 })
12 bench('pop loop', () => {
13 while (testArray.length > 0) {
14 testArray.pop()
15 }
16 })
17 bench('splice', () => {
18 testArray.splice(0, testArray.length)
19 })
20 bench('shift loop', () => {
21 while (testArray.length > 0) {
22 testArray.shift()
23 }
24 })
25 bench('initialize', () => {
26 testArray = []
27 })
28 })
29
30 await run({
31 units: true,
32 })