X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fbenchmarks-utils.js;h=c04162e1a617d704708b56496040640947e22171;hb=7cf00f70a6dffca3af737ea9193a6c3be69ac0b7;hp=4e3cdc9c3af590c7e9812bf80abd81d3743155e8;hpb=d1a9aa414b60e38c91f5623f3572dc46c50f5f14;p=poolifier.git diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index 4e3cdc9c..c04162e1 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -1,8 +1,4 @@ -const WorkerFunctions = { - jsonIntegerSerialization: 'jsonIntegerSerialization', - fibonacci: 'fibonacci', - factorial: 'factorial' -} +const { WorkerFunctions } = require('./benchmarks-types') async function runPoolifierTest (pool, { tasks, workerData }) { return new Promise((resolve, reject) => { @@ -13,7 +9,7 @@ async function runPoolifierTest (pool, { tasks, workerData }) { .then(() => { executions++ if (executions === tasks) { - return resolve('FINISH') + return resolve({ ok: 1 }) } return null }) @@ -35,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 } @@ -81,13 +80,7 @@ function executeWorkerFunction (data) { } } -const LIST_FORMATTER = new Intl.ListFormat('en-US', { - style: 'long', - type: 'conjunction' -}) - module.exports = { - LIST_FORMATTER, WorkerFunctions, executeWorkerFunction, generateRandomInteger,