1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

update benchmarks

This commit is contained in:
leibale
2021-12-07 11:01:42 -05:00
parent 12173e1cd7
commit b68f79538c
17 changed files with 248 additions and 91 deletions

View File

@@ -4,6 +4,7 @@ import { promises as fs } from 'fs';
import { fork } from 'child_process';
import { URL, fileURLToPath } from 'url';
import { once } from 'events';
import { extname } from 'path';
async function getPathChoices() {
const dirents = await fs.readdir(new URL('.', import.meta.url), {
@@ -32,11 +33,23 @@ async function getName() {
}
const runnerPath = fileURLToPath(new URL('runner.js', import.meta.url)),
path = new URL(`${await getName()}/`, import.meta.url),
metadata = await import(new URL('index.js', path));
path = new URL(`${await getName()}/`, import.meta.url);
async function getMetadata() {
try {
return await import(new URL('index.js', path));
} catch (err) {
if (err.code === 'ERR_MODULE_NOT_FOUND') return;
throw err;
}
}
const metadata = await getMetadata(),
timestamp = Date.now();
for (const file of await fs.readdir(path)) {
if (file === 'index.js') continue;
if (file === 'index.js' || extname(file) !== '.js') continue;
const benchmarkProcess = fork(runnerPath, [
...argv,
@@ -45,6 +58,9 @@ for (const file of await fs.readdir(path)) {
]);
await once(benchmarkProcess, 'message');
benchmarkProcess.send(metadata);
benchmarkProcess.send({
metadata,
timestamp
});
await once(benchmarkProcess, 'close');
}