repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-worker_thr...
[poolifier.git]
/
benchmarks
/
benchmarks-utils.mjs
diff --git
a/benchmarks/benchmarks-utils.mjs
b/benchmarks/benchmarks-utils.mjs
index 48c8fc3e7cb7dacd019a4ca3ac8fa28749c61db5..e8c67583bf1958d7f2f0a2294bd2f1c399ca9b49 100644
(file)
--- a/
benchmarks/benchmarks-utils.mjs
+++ b/
benchmarks/benchmarks-utils.mjs
@@
-8,7
+8,7
@@
import {
PoolTypes,
WorkerTypes
} from '../lib/index.mjs'
PoolTypes,
WorkerTypes
} from '../lib/index.mjs'
-import {
Worker
Functions } from './benchmarks-types.mjs'
+import {
Task
Functions } from './benchmarks-types.mjs'
export const runTest = async (pool, { taskExecutions, workerData }) => {
return new Promise((resolve, reject) => {
export const runTest = async (pool, { taskExecutions, workerData }) => {
return new Promise((resolve, reject) => {
@@
-23,7
+23,7
@@
export const runTest = async (pool, { taskExecutions, workerData }) => {
}
return null
})
}
return null
})
- .catch(
err
=> {
+ .catch(
(err)
=> {
console.error(err)
return reject(err)
})
console.error(err)
return reject(err)
})
@@
-46,7
+46,7
@@
export const generateRandomInteger = (
return Math.floor(Math.random() * (max + 1))
}
return Math.floor(Math.random() * (max + 1))
}
-const jsonIntegerSerialization =
n
=> {
+const jsonIntegerSerialization =
(n)
=> {
for (let i = 0; i < n; i++) {
const o = {
a: i
for (let i = 0; i < n; i++) {
const o = {
a: i
@@
-61,7
+61,7
@@
const jsonIntegerSerialization = n => {
* @param {number} n - The number of fibonacci numbers to generate.
* @returns {number} - The nth fibonacci number.
*/
* @param {number} n - The number of fibonacci numbers to generate.
* @returns {number} - The nth fibonacci number.
*/
-const fibonacci =
n
=> {
+const fibonacci =
(n)
=> {
if (n <= 1) return n
return fibonacci(n - 1) + fibonacci(n - 2)
}
if (n <= 1) return n
return fibonacci(n - 1) + fibonacci(n - 2)
}
@@
-71,7
+71,7
@@
const fibonacci = n => {
* @param {number} n - The number to calculate the factorial of.
* @returns {number} - The factorial of n.
*/
* @param {number} n - The number to calculate the factorial of.
* @returns {number} - The factorial of n.
*/
-const factorial =
n
=> {
+const factorial =
(n)
=> {
if (n === 0) {
return 1
}
if (n === 0) {
return 1
}
@@
-100,18
+100,18
@@
const readWriteFiles = (
return { ok: 1 }
}
return { ok: 1 }
}
-export const execute
WorkerFunction = data
=> {
+export const execute
TaskFunction = (data)
=> {
switch (data.function) {
switch (data.function) {
- case
Worker
Functions.jsonIntegerSerialization:
+ case
Task
Functions.jsonIntegerSerialization:
return jsonIntegerSerialization(data.taskSize || 1000)
return jsonIntegerSerialization(data.taskSize || 1000)
- case
Worker
Functions.fibonacci:
+ case
Task
Functions.fibonacci:
return fibonacci(data.taskSize || 1000)
return fibonacci(data.taskSize || 1000)
- case
Worker
Functions.factorial:
+ case
Task
Functions.factorial:
return factorial(data.taskSize || 1000)
return factorial(data.taskSize || 1000)
- case
Worker
Functions.readWriteFiles:
+ case
Task
Functions.readWriteFiles:
return readWriteFiles(data.taskSize || 1000)
default:
return readWriteFiles(data.taskSize || 1000)
default:
- throw new Error('Unknown
worker
function')
+ throw new Error('Unknown
task
function')
}
}
}
}