X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fbenchmarks-utils.js;h=6eed668bd16b33d9f7f6598ed2a680285d884e36;hb=a230240d39d3a8bbd986900986795f0bbabb1a72;hp=62613c7e877308195871675021cc23cbba700a06;hpb=ca6c7d70082311f3cc503090cf507ce36582b9b6;p=poolifier.git diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index 62613c7e..6eed668b 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -7,7 +7,7 @@ async function runPoolifierTest (pool, { tasks, workerData }) { pool .execute(workerData) .then(() => { - executions++ + ++executions if (executions === tasks) { return resolve({ ok: 1 }) } @@ -31,8 +31,11 @@ function jsonIntegerSerialization (n) { } function generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) { + if (max < min || max < 0 || min < 0) { + throw new RangeError('Invalid interval') + } max = Math.floor(max) - if (min) { + if (min != null && min !== 0) { min = Math.ceil(min) return Math.floor(Math.random() * (max - min + 1)) + min } @@ -59,9 +62,8 @@ function fibonacci (n) { function factorial (n) { if (n === 0) { return 1 - } else { - return factorial(n - 1) * n } + return factorial(n - 1) * n } function executeWorkerFunction (data) {