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
[poolifier.git]
/
benchmarks
/
worker-selection
/
least.mjs
diff --git
a/benchmarks/worker-selection/least.mjs
b/benchmarks/worker-selection/least.mjs
index ca5de3c1821de7bed57680fe1a3acd4aae3e398a..189a5e6c8f05da89f70fe25e0ffe8dc5a8af7f64 100644
(file)
--- a/
benchmarks/worker-selection/least.mjs
+++ b/
benchmarks/worker-selection/least.mjs
@@
-2,6
+2,12
@@
import { randomInt } from 'node:crypto'
import { bench, group, run } from 'tatami-ng'
import { bench, group, run } from 'tatami-ng'
+/**
+ *
+ * @param numberOfWorkers
+ * @param maxNumberOfTasksPerWorker
+ * @returns
+ */
function generateRandomTasksMap (
numberOfWorkers,
maxNumberOfTasksPerWorker = 10
function generateRandomTasksMap (
numberOfWorkers,
maxNumberOfTasksPerWorker = 10
@@
-16,9
+22,14
@@
function generateRandomTasksMap (
const tasksMap = generateRandomTasksMap(60, 20)
const tasksMap = generateRandomTasksMap(60, 20)
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function loopSelect (tasksMap) {
let minKey
function loopSelect (tasksMap) {
let minKey
- let minValue =
Infinity
+ let minValue =
Number.POSITIVE_INFINITY
for (const [key, value] of tasksMap) {
if (value === 0) {
return key
for (const [key, value] of tasksMap) {
if (value === 0) {
return key
@@
-30,6
+41,11
@@
function loopSelect (tasksMap) {
return [minKey, minValue]
}
return [minKey, minValue]
}
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function arraySortSelect (tasksMap) {
const tasksArray = Array.from(tasksMap)
return tasksArray.sort((a, b) => {
function arraySortSelect (tasksMap) {
const tasksArray = Array.from(tasksMap)
return tasksArray.sort((a, b) => {
@@
-54,12
+70,27
@@
const randomPivotIndexSelect = (leftIndex, rightIndex) => {
return randomInt(leftIndex, rightIndex)
}
return randomInt(leftIndex, rightIndex)
}
+/**
+ *
+ * @param array
+ * @param index1
+ * @param index2
+ */
function swap (array, index1, index2) {
const tmp = array[index1]
array[index1] = array[index2]
array[index2] = tmp
}
function swap (array, index1, index2) {
const tmp = array[index1]
array[index1] = array[index2]
array[index2] = tmp
}
+/**
+ *
+ * @param array
+ * @param leftIndex
+ * @param rightIndex
+ * @param pivotIndex
+ * @param compare
+ * @returns
+ */
function partition (
array,
leftIndex,
function partition (
array,
leftIndex,
@@
-80,6
+111,16
@@
function partition (
return storeIndex
}
return storeIndex
}
+/**
+ *
+ * @param array
+ * @param k
+ * @param leftIndex
+ * @param rightIndex
+ * @param compare
+ * @param pivotIndexSelect
+ * @returns
+ */
function selectLoop (
array,
k,
function selectLoop (
array,
k,
@@
-102,6
+143,16
@@
function selectLoop (
}
}
}
}
+/**
+ *
+ * @param array
+ * @param k
+ * @param leftIndex
+ * @param rightIndex
+ * @param compare
+ * @param pivotIndexSelect
+ * @returns
+ */
function selectRecursion (
array,
k,
function selectRecursion (
array,
k,
@@
-122,6
+173,11
@@
function selectRecursion (
}
}
}
}
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function quickSelectLoop (tasksMap) {
const tasksArray = Array.from(tasksMap)
function quickSelectLoop (tasksMap) {
const tasksArray = Array.from(tasksMap)
@@
-130,6
+186,11
@@
function quickSelectLoop (tasksMap) {
})
}
})
}
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function quickSelectLoopRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)
function quickSelectLoopRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)
@@
-145,6
+206,11
@@
function quickSelectLoopRandomPivot (tasksMap) {
)
}
)
}
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function quickSelectRecursion (tasksMap) {
const tasksArray = Array.from(tasksMap)
function quickSelectRecursion (tasksMap) {
const tasksArray = Array.from(tasksMap)
@@
-153,6
+219,11
@@
function quickSelectRecursion (tasksMap) {
})
}
})
}
+/**
+ *
+ * @param tasksMap
+ * @returns
+ */
function quickSelectRecursionRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)
function quickSelectRecursionRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)