Bump eslint-define-config from 1.14.0 to 1.15.0
[benchmarks-js.git] / empty-array.js
CommitLineData
8e5cf49d 1const Benchmark = require('benny')
feb629fe 2const { generateRandomNumberArray } = require('./benchmark-utils')
2deff321 3
bb578730
JB
4const size = 10000
5let testArray = generateRandomNumberArray(size)
2deff321 6
8e5cf49d 7Benchmark.suite(
bb578730 8 `Empty array with ${size} elements`,
8e5cf49d 9 Benchmark.add('length = 0', () => {
2deff321 10 testArray.length = 0
8e5cf49d 11 }),
e2bfb549 12 Benchmark.add('pop loop', () => {
2deff321
JB
13 while (testArray.length > 0) {
14 testArray.pop()
15 }
8e5cf49d 16 }),
e2bfb549 17 Benchmark.add('splice', () => {
2deff321 18 testArray.splice(0, testArray.length)
8e5cf49d
JB
19 }),
20 Benchmark.add('shift loop', () => {
2deff321
JB
21 while (testArray.length > 0) {
22 testArray.shift()
23 }
8e5cf49d
JB
24 }),
25 Benchmark.add('new init', () => {
2deff321 26 testArray = []
8e5cf49d
JB
27 }),
28 Benchmark.cycle(),
29 Benchmark.complete(),
fb341cfe
JB
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 })
8e5cf49d 33)