repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps): bump poolifier in /examples/typescript/smtp-client-pool
[poolifier.git]
/
benchmarks
/
worker-selection
/
least.mjs
diff --git
a/benchmarks/worker-selection/least.mjs
b/benchmarks/worker-selection/least.mjs
index 2abbae8275c147187a486b368ffec84c3bdcd579..ca5de3c1821de7bed57680fe1a3acd4aae3e398a 100644
(file)
--- a/
benchmarks/worker-selection/least.mjs
+++ b/
benchmarks/worker-selection/least.mjs
@@
-1,5
+1,6
@@
-import Benchmark from 'benchmark'
-import { LIST_FORMATTER, generateRandomInteger } from '../benchmarks-utils.mjs'
+import { randomInt } from 'node:crypto'
+
+import { bench, group, run } from 'tatami-ng'
function generateRandomTasksMap (
numberOfWorkers,
function generateRandomTasksMap (
numberOfWorkers,
@@
-7,7
+8,7
@@
function generateRandomTasksMap (
) {
const tasksArray = []
for (let i = 0; i < numberOfWorkers; i++) {
) {
const tasksArray = []
for (let i = 0; i < numberOfWorkers; i++) {
- const task = [i,
generateRandomInteger
(maxNumberOfTasksPerWorker)]
+ const task = [i,
randomInt
(maxNumberOfTasksPerWorker)]
tasksArray.push(task)
}
return new Map(tasksArray)
tasksArray.push(task)
}
return new Map(tasksArray)
@@
-50,7
+51,7
@@
const defaultPivotIndexSelect = (leftIndex, rightIndex) => {
}
const randomPivotIndexSelect = (leftIndex, rightIndex) => {
}
const randomPivotIndexSelect = (leftIndex, rightIndex) => {
- return
generateRandomInteger(rightIndex, lef
tIndex)
+ return
randomInt(leftIndex, righ
tIndex)
}
function swap (array, index1, index2) {
}
function swap (array, index1, index2) {
@@
-167,31
+168,25
@@
function quickSelectRecursionRandomPivot (tasksMap) {
)
}
)
}
-new Benchmark.Suite('Least used worker tasks distribution')
-
.add
('Loop select', () => {
+group('Least used worker tasks distribution', () => {
+
bench
('Loop select', () => {
loopSelect(tasksMap)
})
loopSelect(tasksMap)
})
-
.add
('Array sort select', () => {
+
bench
('Array sort select', () => {
arraySortSelect(tasksMap)
})
arraySortSelect(tasksMap)
})
-
.add
('Quick select loop', () => {
+
bench
('Quick select loop', () => {
quickSelectLoop(tasksMap)
})
quickSelectLoop(tasksMap)
})
-
.add
('Quick select loop with random pivot', () => {
+
bench
('Quick select loop with random pivot', () => {
quickSelectLoopRandomPivot(tasksMap)
})
quickSelectLoopRandomPivot(tasksMap)
})
-
.add
('Quick select recursion', () => {
+
bench
('Quick select recursion', () => {
quickSelectRecursion(tasksMap)
})
quickSelectRecursion(tasksMap)
})
-
.add
('Quick select recursion with random pivot', () => {
+
bench
('Quick select recursion with random pivot', () => {
quickSelectRecursionRandomPivot(tasksMap)
})
quickSelectRecursionRandomPivot(tasksMap)
})
- .on('cycle', event => {
- console.info(event.target.toString())
- })
- .on('complete', function () {
- console.info(
- 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
- )
- })
- .run()
+})
+
+await run({ units: true })