From: Jérôme Benoit Date: Sun, 6 Jun 2021 18:51:56 +0000 (+0200) Subject: Refine a bit eslint configuration X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e9bfc28e575ac3a05a748526e241cb584f55480e;p=benchmarks-js.git Refine a bit eslint configuration Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.js b/.eslintrc.js index 5c8e260..27aa200 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,4 @@ -// @ts-check +// eslint-disable-next-line node/no-unpublished-require const { defineConfig } = require('eslint-define-config') module.exports = defineConfig({ @@ -10,6 +10,8 @@ module.exports = defineConfig({ extends: [ 'standard', 'eslint:recommended', + 'plugin:node/recommended', + 'plugin:jsdoc/recommended', 'plugin:import/recommended', 'plugin:promise/recommended', 'plugin:prettierx/standardx' diff --git a/benchmark-utils.js b/benchmark-utils.js index 4cddc6d..c1b68c5 100644 --- a/benchmark-utils.js +++ b/benchmark-utils.js @@ -1,3 +1,7 @@ +/** + * @param max + * @param min + */ function generateRandomInteger (max, min = 0) { if (min) { return Math.floor(Math.random() * (max - min + 1) + min) diff --git a/busy-wait.js b/busy-wait.js index 4742018..ed06c52 100644 --- a/busy-wait.js +++ b/busy-wait.js @@ -5,11 +5,18 @@ const suite = new Benchmark.Suite() 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 diff --git a/promise-handling.js b/promise-handling.js index 182ba77..03a78e2 100644 --- a/promise-handling.js +++ b/promise-handling.js @@ -3,10 +3,16 @@ const { LIST_FORMATTER } = require('./benchmark-utils') const suite = new Benchmark.Suite() +/** + * + */ function promise () { return new Promise() } +/** + * + */ async function asyncFunction () { await promise() } diff --git a/quick-select.js b/quick-select.js index cf8f235..57c4dee 100644 --- a/quick-select.js +++ b/quick-select.js @@ -3,6 +3,10 @@ const { generateRandomInteger, LIST_FORMATTER } = require('./benchmark-utils') const suite = new Benchmark.Suite() +/** + * @param numberOfWorkers + * @param maxNumberOfTasksPerWorker + */ function generateRandomTasksMap ( numberOfWorkers, maxNumberOfTasksPerWorker = 10 @@ -17,6 +21,9 @@ function generateRandomTasksMap ( const tasksMap = generateRandomTasksMap(60, 20) +/** + * @param tasksMap + */ function loopSelect (tasksMap) { let minValue = Infinity let minKey @@ -31,6 +38,9 @@ function loopSelect (tasksMap) { return [minKey, minValue] } +/** + * @param tasksMap + */ function arraySortSelect (tasksMap) { const tasksArray = Array.from(tasksMap) return tasksArray.sort((a, b) => { @@ -55,12 +65,24 @@ const randomPivotIndexSelect = (leftIndex, rightIndex) => { 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, @@ -81,6 +103,14 @@ function partition ( return storeIndex } +/** + * @param array + * @param k + * @param leftIndex + * @param rightIndex + * @param compare + * @param pivotIndexSelect + */ function selectLoop ( array, k, @@ -103,6 +133,14 @@ function selectLoop ( } } +/** + * @param array + * @param k + * @param leftIndex + * @param rightIndex + * @param compare + * @param pivotIndexSelect + */ function selectRecursion ( array, k, @@ -123,6 +161,9 @@ function selectRecursion ( } } +/** + * @param tasksMap + */ function quickSelectLoop (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -131,6 +172,9 @@ function quickSelectLoop (tasksMap) { }) } +/** + * @param tasksMap + */ function quickSelectLoopRandomPivot (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -146,6 +190,9 @@ function quickSelectLoopRandomPivot (tasksMap) { ) } +/** + * @param tasksMap + */ function quickSelectRecursion (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -154,6 +201,9 @@ function quickSelectRecursion (tasksMap) { }) } +/** + * @param tasksMap + */ function quickSelectRecursionRandomPivot (tasksMap) { const tasksArray = Array.from(tasksMap)