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', () => {
}
suite
- .add('await promise', async function () {
+ .add('await promise', async () => {
await asyncFunction()
})
- .add('promise', function () {
+ .add('promise', () => {
asyncFunction()
})
- .on('cycle', function (event) {
+ .on('cycle', event => {
console.log(event.target.toString())
})
.on('complete', function () {
-const Benchmark = require('benchmark')
-const { generateRandomInteger, LIST_FORMATTER } = require('./benchmark-utils')
-
-const suite = new Benchmark.Suite()
+const Benchmark = require('benny')
+const { generateRandomInteger } = require('./benchmark-utils')
/**
* @param numberOfWorkers
)
}
-// console.log(Array.from(tasksMap))
-// console.log(loopSelect(tasksMap))
-// console.log(arraySortSelect(tasksMap))
-// console.log(quickSelectLoop(tasksMap))
-// console.log(quickSelectLoopRandomPivot(tasksMap))
-// console.log(quickSelectRecursion(tasksMap))
-// console.log(quickSelectRecursionRandomPivot(tasksMap))
-
-suite
- .add('Loop select', function () {
+Benchmark.suite(
+ 'Quick select',
+ Benchmark.add('Loop select', () => {
loopSelect(tasksMap)
- })
- .add('Array sort select', function () {
+ }),
+ Benchmark.add('Array sort select', () => {
arraySortSelect(tasksMap)
- })
- .add('Quick select loop', function () {
+ }),
+ Benchmark.add('Quick select loop', () => {
quickSelectLoop(tasksMap)
- })
- .add('Quick select loop with random pivot', function () {
+ }),
+ Benchmark.add('Quick select loop with random pivot', () => {
quickSelectLoopRandomPivot(tasksMap)
- })
- .add('Quick select recursion', function () {
+ }),
+ Benchmark.add('Quick select recursion', () => {
quickSelectRecursion(tasksMap)
- })
- .add('Quick select recursion with random pivot', function () {
+ }),
+ Benchmark.add('Quick select recursion with random pivot', () => {
quickSelectRecursionRandomPivot(tasksMap)
+ }),
+ Benchmark.cycle(),
+ Benchmark.complete(),
+ Benchmark.save({
+ file: 'quick-select',
+ format: 'json',
+ details: true
+ }),
+ Benchmark.save({
+ file: 'quick-select',
+ format: 'chart.html',
+ details: true
+ }),
+ Benchmark.save({
+ file: 'quick-select',
+ format: 'table.html',
+ details: true
})
- .on('cycle', function (event) {
- console.log(event.target.toString())
- })
- .on('complete', function () {
- console.log(
- 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
- )
- // eslint-disable-next-line n/no-process-exit
- process.exit()
- })
- .run()
+)
Benchmark.suite(
'Random Integer Generator',
- Benchmark.add('Secure random integer generator', function () {
+ Benchmark.add('Secure random integer generator', () => {
getSecureRandomInteger(maximum)
}),
- Benchmark.add('Random integer generator', function () {
+ Benchmark.add('Random integer generator', () => {
getRandomInteger(maximum)
}),
Benchmark.cycle(),