This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

29
node_modules/piscina/benchmark/simple-benchmark.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
const { Piscina } = require('..');
const { resolve } = require('path');
async function simpleBenchmark ({ duration = 10000 } = {}) {
const pool = new Piscina({ filename: resolve(__dirname, 'fixtures/add.js') });
let done = 0;
const results = [];
const start = process.hrtime.bigint();
while (pool.queueSize === 0) {
results.push(scheduleTasks());
}
async function scheduleTasks () {
while ((process.hrtime.bigint() - start) / 1_000_000n < duration) {
await pool.run({ a: 4, b: 6 });
done++;
}
}
await Promise.all(results);
return done / duration * 1e3;
}
simpleBenchmark().then((opsPerSecond) => {
console.log(`opsPerSecond: ${opsPerSecond} (with default taskQueue)`);
});