Files
dev/third_party/pi/packages/agent/benchmark/session/loaded-footprint-worker.ts
alexion 4def357d09 chore(vendor): import pi 0.85.1
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
2026-09-14 10:48:47 -04:00

35 lines
1.3 KiB
TypeScript

import {
STORAGE_BENCHMARK_DATASETS,
seedStorageBenchmark,
} from "../../src/harness/session/testing/index.ts";
import { storageBenchmarkTargets } from "./storage-targets.ts";
function collectGarbage(): void {
if (globalThis.gc === undefined) throw new Error("Loaded footprint measurement requires Node.js --expose-gc");
for (let index = 0; index < 3; index++) globalThis.gc();
}
const [targetName, datasetName] = process.argv.slice(2);
const target = storageBenchmarkTargets.find((candidate) => candidate.name === targetName);
if (target === undefined) throw new Error(`Unknown storage benchmark target: ${targetName}`);
const dataset = STORAGE_BENCHMARK_DATASETS.find((candidate) => candidate.name === datasetName);
if (dataset === undefined) throw new Error(`Unknown storage benchmark dataset: ${datasetName}`);
await using fixture = await target.createFixture();
collectGarbage();
const before = process.memoryUsage();
await seedStorageBenchmark(fixture.storage, dataset);
collectGarbage();
const after = process.memoryUsage();
console.log(
JSON.stringify({
target: target.name,
dataset: dataset.name,
entryCount: dataset.entryCount,
heapUsedBytes: after.heapUsed - before.heapUsed,
rssBytes: after.rss - before.rss,
externalBytes: after.external - before.external,
}),
);