+const crypto = require('crypto')
const fs = require('fs')
const {
PoolTypes,
/**
* Intentionally inefficient implementation.
- *
* @param {number} n - The number of fibonacci numbers to generate.
* @returns {number} - The nth fibonacci number.
*/
/**
* Intentionally inefficient implementation.
- *
* @param {number} n - The number to calculate the factorial of.
* @returns {number} - The factorial of n.
*/
return factorial(n - 1) * n
}
-function readWriteFiles (n) {
- const baseDirectory = '/tmp/poolifier-benchmarks'
- if (fs.existsSync(baseDirectory) === false) {
- fs.mkdirSync(baseDirectory, { recursive: true })
+function readWriteFiles (
+ n,
+ baseDirectory = `/tmp/poolifier-benchmarks/${crypto.randomInt(
+ 281474976710655
+ )}`
+) {
+ if (fs.existsSync(baseDirectory) === true) {
+ fs.rmSync(baseDirectory, { recursive: true })
}
+ fs.mkdirSync(baseDirectory, { recursive: true })
for (let i = 0; i < n; i++) {
const filePath = `${baseDirectory}/${i}`
fs.writeFileSync(filePath, i.toString(), {
})
fs.readFileSync(filePath, 'utf8')
}
+ fs.rmSync(baseDirectory, { recursive: true })
}
function executeWorkerFunction (data) {
}
}
-function buildPool (poolType, poolSize, workerType, poolOptions) {
+function buildPool (workerType, poolType, poolSize, poolOptions) {
switch (poolType) {
case PoolTypes.FIXED:
switch (workerType) {