-// @ts-check
+// eslint-disable-next-line node/no-unpublished-require
const { defineConfig } = require('eslint-define-config')
module.exports = defineConfig({
extends: [
'standard',
'eslint:recommended',
+ 'plugin:node/recommended',
+ 'plugin:jsdoc/recommended',
'plugin:import/recommended',
'plugin:promise/recommended',
'plugin:prettierx/standardx'
const timeout = 2000
+/**
+ * @param timeoutMs
+ */
function dummyTimeoutBusyWait (timeoutMs) {
const timeoutDateMs = Date.now() + timeoutMs
do {} while (Date.now() < timeoutDateMs)
}
+/**
+ * @param timeoutMs
+ * @param delayMs
+ */
function setIntervalTimeoutBusyWait (timeoutMs, delayMs = 200) {
const tries = Math.round(timeoutMs / delayMs)
let count = 0
const suite = new Benchmark.Suite()
+/**
+ * @param numberOfWorkers
+ * @param maxNumberOfTasksPerWorker
+ */
function generateRandomTasksMap (
numberOfWorkers,
maxNumberOfTasksPerWorker = 10
const tasksMap = generateRandomTasksMap(60, 20)
+/**
+ * @param tasksMap
+ */
function loopSelect (tasksMap) {
let minValue = Infinity
let minKey
return [minKey, minValue]
}
+/**
+ * @param tasksMap
+ */
function arraySortSelect (tasksMap) {
const tasksArray = Array.from(tasksMap)
return tasksArray.sort((a, b) => {
return generateRandomInteger(leftIndex, rightIndex)
}
+/**
+ * @param array
+ * @param index1
+ * @param index2
+ */
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
+ */
function partition (
array,
leftIndex,
return storeIndex
}
+/**
+ * @param array
+ * @param k
+ * @param leftIndex
+ * @param rightIndex
+ * @param compare
+ * @param pivotIndexSelect
+ */
function selectLoop (
array,
k,
}
}
+/**
+ * @param array
+ * @param k
+ * @param leftIndex
+ * @param rightIndex
+ * @param compare
+ * @param pivotIndexSelect
+ */
function selectRecursion (
array,
k,
}
}
+/**
+ * @param tasksMap
+ */
function quickSelectLoop (tasksMap) {
const tasksArray = Array.from(tasksMap)
})
}
+/**
+ * @param tasksMap
+ */
function quickSelectLoopRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)
)
}
+/**
+ * @param tasksMap
+ */
function quickSelectRecursion (tasksMap) {
const tasksArray = Array.from(tasksMap)
})
}
+/**
+ * @param tasksMap
+ */
function quickSelectRecursionRandomPivot (tasksMap) {
const tasksArray = Array.from(tasksMap)