build(deps-dev): apply updates
[benchmarks-js.git] / empty-array.mjs
CommitLineData
4676a95c 1import { bench, group, run } from 'tatami-ng'
0c01f51c 2
95d31631 3import { generateRandomNumberArray } from './benchmark-utils.mjs'
2deff321 4
bb578730
JB
5const size = 10000
6let testArray = generateRandomNumberArray(size)
2deff321 7
ab9a08f3
JB
8group(`Empty array with ${size} elements`, () => {
9 bench('length = 0', () => {
2deff321 10 testArray.length = 0
ab9a08f3
JB
11 })
12 bench('pop loop', () => {
2deff321
JB
13 while (testArray.length > 0) {
14 testArray.pop()
15 }
ab9a08f3
JB
16 })
17 bench('splice', () => {
2deff321 18 testArray.splice(0, testArray.length)
ab9a08f3
JB
19 })
20 bench('shift loop', () => {
2deff321
JB
21 while (testArray.length > 0) {
22 testArray.shift()
23 }
ab9a08f3
JB
24 })
25 bench('initialize', () => {
2deff321 26 testArray = []
ab9a08f3
JB
27 })
28})
29
30await run({
ebf80fe4 31 units: true,
ab9a08f3 32})