Files
MUA-Mikes-Unraid-Agent/scripts/memory-benchmark.ts
T

14 lines
646 B
TypeScript

import { runShell } from "../src/helpers";
// Isolated synthetic producer. No NAS, network access or host file content.
const mib = Number(process.argv[2] ?? 64);
if (!Number.isInteger(mib) || mib < 1 || mib > 128) throw new Error("Use 1..128 MiB");
const before = process.memoryUsage();
const result = JSON.parse(await runShell(`head -c ${mib * 1024 * 1024} /dev/zero | tr '\\000' x`, 30));
const after = process.memoryUsage();
Bun.gc(true);
console.log(JSON.stringify({
runtime: Bun.version, produced_mib: mib, returned_chars: result.stdout.length,
truncated: result.truncated ?? null, before, after, after_gc: process.memoryUsage(),
}));