mirror of
https://github.com/earendil-works/pi.git
synced 2026-10-02 00:35:27 +08:00
Replace the tsgo native preview with typescript@7.0.2 and port the check scripts to the TS 7 API. Target ES2024, drop useDefineForClassFields: false and unused decorator options, and enable verbatimModuleSyntax. Replace tsx with node plus the source resolver hook, passed to --import as a file URL. closes #9965
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
import { promisify } from "node:util";
|
|
import { STORAGE_BENCHMARK_DATASETS } from "../../src/harness/session/testing/index.ts";
|
|
import { storageBenchmarkTargets } from "./storage-targets.ts";
|
|
|
|
interface LoadedFootprintResult {
|
|
readonly target: string;
|
|
readonly dataset: string;
|
|
readonly entryCount: number;
|
|
readonly heapUsedBytes: number;
|
|
readonly rssBytes: number;
|
|
readonly externalBytes: number;
|
|
}
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const packageRoot = fileURLToPath(new URL("../..", import.meta.url));
|
|
const workerPath = fileURLToPath(new URL("./loaded-footprint-worker.ts", import.meta.url));
|
|
// Resolve workspace packages to their sources, matching the root tsconfig paths.
|
|
const sourceResolverUrl = new URL("../../../coding-agent/src/experimental/source-resolver.ts", import.meta.url).href;
|
|
const results: LoadedFootprintResult[] = [];
|
|
|
|
for (const target of storageBenchmarkTargets) {
|
|
for (const dataset of STORAGE_BENCHMARK_DATASETS) {
|
|
const { stdout } = await execFileAsync(
|
|
process.execPath,
|
|
[
|
|
"--expose-gc",
|
|
"--import",
|
|
sourceResolverUrl,
|
|
workerPath,
|
|
target.name,
|
|
dataset.name,
|
|
],
|
|
{ cwd: packageRoot },
|
|
);
|
|
results.push(JSON.parse(stdout) as LoadedFootprintResult);
|
|
}
|
|
}
|
|
|
|
const mebibytes = (bytes: number): string => (bytes / 1024 / 1024).toFixed(2);
|
|
console.log("Loaded footprint (synthetic payloads generated and ingested after the baseline):");
|
|
console.table(
|
|
results.map((result) => ({
|
|
backend: result.target,
|
|
dataset: result.dataset,
|
|
"heap MiB": mebibytes(result.heapUsedBytes),
|
|
"heap bytes/entry": Math.round(result.heapUsedBytes / result.entryCount),
|
|
"RSS MiB": mebibytes(result.rssBytes),
|
|
"external MiB": mebibytes(result.externalBytes),
|
|
})),
|
|
);
|