X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=benchmarks%2Finternal%2Fbenchmark-utils.js;h=a915a044211fa7c8c14f98c369e82c30739c1733;hb=9beb6c8fae8263582479c18d9f4bc2520efe9280;hp=f84227d3ff01b52ec21335e2cf88fcd880325dee;hpb=ff5e76e152be8540cba8118bb4e2b9da314dfff5;p=poolifier.git diff --git a/benchmarks/internal/benchmark-utils.js b/benchmarks/internal/benchmark-utils.js index f84227d3..a915a044 100644 --- a/benchmarks/internal/benchmark-utils.js +++ b/benchmarks/internal/benchmark-utils.js @@ -1,7 +1,7 @@ -async function runTest (pool, { tasks, workerData }) { +async function runPoolifierTest (pool, { tasks, workerData }) { return new Promise((resolve, reject) => { let executions = 0 - for (let i = 0; i <= tasks; i++) { + for (let i = 1; i <= tasks; i++) { pool .execute(workerData) .then(res => { @@ -16,4 +16,18 @@ async function runTest (pool, { tasks, workerData }) { }) } -module.exports = { runTest } +function generateRandomInteger (max, min = 0) { + max = Math.floor(max) + if (min) { + min = Math.ceil(min) + return Math.floor(Math.random() * (max - min + 1)) + min + } + return Math.floor(Math.random() * (max + 1)) +} + +const LIST_FORMATTER = new Intl.ListFormat('en-US', { + style: 'long', + type: 'conjunction' +}) + +module.exports = { generateRandomInteger, LIST_FORMATTER, runPoolifierTest }