const Benchmark = require('benny')
+const { generateRandomNumberArray } = require('./benchmark-utils')
-let testArray = [
- 83, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62,
- 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28,
- 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93,
- 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32,
- 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67,
- 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23, 56, 32,
- 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828, 234, 23,
- 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27, 29, 2828,
- 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28, 93, 27,
- 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99, 36, 28,
- 93, 27, 29, 2828, 234, 23, 56, 32, 56, 67, 77, 32, 45, 93, 17, 28, 83, 62, 99,
- 36, 28
-]
+const size = 10000
+let testArray = generateRandomNumberArray(size)
Benchmark.suite(
- 'Empty array',
+ `Empty array with ${size} elements`,
Benchmark.add('length = 0', () => {
testArray.length = 0
}),
- Benchmark.add('pop loop', async () => {
+ Benchmark.add('pop loop', () => {
while (testArray.length > 0) {
testArray.pop()
}
}),
- Benchmark.add('splice', async () => {
+ Benchmark.add('splice', () => {
testArray.splice(0, testArray.length)
}),
Benchmark.add('shift loop', () => {
}),
Benchmark.cycle(),
Benchmark.complete(),
- Benchmark.save({ file: 'empty-array', format: 'chart.html' }),
- Benchmark.save({ file: 'empty-array', format: 'table.html' })
+ Benchmark.save({ file: 'empty-array', format: 'json', details: true }),
+ Benchmark.save({ file: 'empty-array', format: 'chart.html', details: true }),
+ Benchmark.save({ file: 'empty-array', format: 'table.html', details: true })
)