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
This commit is contained in:
34
third_party/pi/packages/agent/benchmark/session/loaded-footprint-worker.ts
vendored
Normal file
34
third_party/pi/packages/agent/benchmark/session/loaded-footprint-worker.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
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,
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user