-import crypto from 'node:crypto'
-import assert from 'node:assert'
-import fs from 'node:fs'
-import Benchmark from 'benchmark'
-import {
+const crypto = require('node:crypto')
+const assert = require('node:assert')
+const fs = require('node:fs')
+const Benchmark = require('benchmark')
+const {
DynamicClusterPool,
DynamicThreadPool,
FixedClusterPool,
PoolTypes,
WorkerChoiceStrategies,
WorkerTypes
-} from '../lib/index.mjs'
-import { TaskFunctions } from './benchmarks-types.mjs'
+} = require('../lib/index.js')
+const { TaskFunctions } = require('./benchmarks-types.js')
-export const buildPoolifierPool = (
- workerType,
- poolType,
- poolSize,
- poolOptions
-) => {
+const buildPoolifierPool = (workerType, poolType, poolSize, poolOptions) => {
switch (poolType) {
case PoolTypes.fixed:
switch (workerType) {
case WorkerTypes.cluster:
return new FixedClusterPool(
poolSize,
- './benchmarks/internal/cluster-worker.mjs',
+ './benchmarks/internal/cluster-worker.js',
poolOptions
)
}
return new DynamicClusterPool(
Math.floor(poolSize / 2),
poolSize,
- './benchmarks/internal/cluster-worker.mjs',
+ './benchmarks/internal/cluster-worker.js',
poolOptions
)
}
}
}
-export const runPoolifierPool = async (
- pool,
- { taskExecutions, workerData }
-) => {
+const runPoolifierPool = async (pool, { taskExecutions, workerData }) => {
return await new Promise((resolve, reject) => {
let executions = 0
for (let i = 1; i <= taskExecutions; i++) {
})
}
-export const runPoolifierPoolBenchmark = async (
+const runPoolifierPoolBenchmark = async (
name,
pool,
{ taskExecutions, workerData }
})
}
-export const LIST_FORMATTER = new Intl.ListFormat('en-US', {
+const LIST_FORMATTER = new Intl.ListFormat('en-US', {
style: 'long',
type: 'conjunction'
})
-export const generateRandomInteger = (
- max = Number.MAX_SAFE_INTEGER,
- min = 0
-) => {
+const generateRandomInteger = (max = Number.MAX_SAFE_INTEGER, min = 0) => {
if (max < min || max < 0 || min < 0) {
throw new RangeError('Invalid interval')
}
return { ok: 1 }
}
-export const executeTaskFunction = data => {
+const executeTaskFunction = data => {
switch (data.function) {
case TaskFunctions.jsonIntegerSerialization:
return jsonIntegerSerialization(data.taskSize || 1000)
throw new Error('Unknown task function')
}
}
+
+module.exports = {
+ LIST_FORMATTER,
+ buildPoolifierPool,
+ executeTaskFunction,
+ generateRandomInteger,
+ runPoolifierPoolBenchmark
+}