const targets = [ { name: "Redis", dir: "client-redis" }, { name: "Memcached", dir: "client-memcached" }, { name: "ArangoDB", dir: "client-arangodb" }, ]; const results: any[] = []; for (const t of targets) { console.log(`\n>>> Running benchmark for ${t.name} ...`); const proc = Bun.spawnSync(["bun", "bench.ts"], { cwd: t.dir, stdout: "pipe", stderr: "pipe" }); const out = proc.stdout.toString(); const err = proc.stderr.toString(); process.stdout.write(out.split("\n").filter(l => !l.startsWith("##RESULT##")).join("\n")); if (err.trim()) process.stderr.write(err); const line = out.split("\n").find(l => l.startsWith("##RESULT## ")); if (line) results.push(JSON.parse(line.slice("##RESULT## ".length))); } function pad(s: string, n: number) { return s.padEnd(n); } function padNum(s: string, n: number) { return s.padStart(n); } const testMeta = [ { idx: 0, title: "Anwendungsfall 1 - Schreiben (Live-Player-Sync, 1 Schluessel)" }, { idx: 1, title: "Anwendungsfall 1 - Lesen (Live-Player-Sync, 1 Schluessel)" }, { idx: 2, title: "Anwendungsfall 2 - Lesen (Region / Fast Travel, 14 Schluessel)" }, { idx: 3, title: "Anwendungsfall 2 - Schreiben (Region / Fast Travel, 14 Schluessel)" }, ]; console.log("\n\n==================== VERGLEICH ===================="); for (const m of testMeta) { console.log(`\n${m.title}`); console.log(` ${pad("DB", 12)} | ${padNum("Ops/s", 11)} | ${padNum("ms/Op", 10)} | ${padNum("Gesamt ms", 11)}`); console.log(` ${"-".repeat(12)}-+-${"-".repeat(11)}-+-${"-".repeat(10)}-+-${"-".repeat(11)}`); const rows = results.map(r => ({ db: r.db, t: r.tests[m.idx] })); const fastest = Math.max(...rows.map(x => x.t.opsPerSec)); for (const row of rows) { const mark = row.t.opsPerSec === fastest ? " <-- am schnellsten" : ""; console.log(` ${pad(row.db, 12)} | ${padNum(Math.round(row.t.opsPerSec).toString(), 11)} | ${padNum(row.t.avgMs.toFixed(4), 10)} | ${padNum(row.t.ms.toFixed(1), 11)}${mark}`); } } console.log("\n==================================================");