mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 13:11:40 +00:00
perf: trim vitest hot imports and refresh manifests
This commit is contained in:
6
scripts/test-update-memory-hotspots-utils.mjs
Normal file
6
scripts/test-update-memory-hotspots-utils.mjs
Normal file
@@ -0,0 +1,6 @@
|
||||
export function matchesHotspotSummaryLane(lane, targetLane, lanePrefixes = []) {
|
||||
if (lane === targetLane) {
|
||||
return true;
|
||||
}
|
||||
return lanePrefixes.some((prefix) => prefix.length > 0 && lane.startsWith(prefix));
|
||||
}
|
||||
@@ -3,12 +3,14 @@ import path from "node:path";
|
||||
import { parseMemoryTraceSummaryLines } from "./test-parallel-memory.mjs";
|
||||
import { normalizeTrackedRepoPath, tryReadJsonFile, writeJsonFile } from "./test-report-utils.mjs";
|
||||
import { unitMemoryHotspotManifestPath } from "./test-runner-manifest.mjs";
|
||||
import { matchesHotspotSummaryLane } from "./test-update-memory-hotspots-utils.mjs";
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {
|
||||
config: "vitest.unit.config.ts",
|
||||
out: unitMemoryHotspotManifestPath,
|
||||
lane: "unit-fast",
|
||||
lanePrefixes: [],
|
||||
logs: [],
|
||||
minDeltaKb: 256 * 1024,
|
||||
limit: 64,
|
||||
@@ -30,6 +32,14 @@ function parseArgs(argv) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if (arg === "--lane-prefix") {
|
||||
const lanePrefix = argv[i + 1];
|
||||
if (typeof lanePrefix === "string" && lanePrefix.length > 0) {
|
||||
args.lanePrefixes.push(lanePrefix);
|
||||
}
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if (arg === "--log") {
|
||||
const logPath = argv[i + 1];
|
||||
if (typeof logPath === "string" && logPath.length > 0) {
|
||||
@@ -109,8 +119,8 @@ if (existing) {
|
||||
}
|
||||
for (const logPath of opts.logs) {
|
||||
const text = fs.readFileSync(logPath, "utf8");
|
||||
const summaries = parseMemoryTraceSummaryLines(text).filter(
|
||||
(summary) => summary.lane === opts.lane,
|
||||
const summaries = parseMemoryTraceSummaryLines(text).filter((summary) =>
|
||||
matchesHotspotSummaryLane(summary.lane, opts.lane, opts.lanePrefixes),
|
||||
);
|
||||
for (const summary of summaries) {
|
||||
for (const record of summary.top) {
|
||||
@@ -142,7 +152,10 @@ const output = {
|
||||
config: opts.config,
|
||||
generatedAt: new Date().toISOString(),
|
||||
defaultMinDeltaKb: opts.minDeltaKb,
|
||||
lane: opts.lane,
|
||||
lane:
|
||||
opts.lanePrefixes.length === 0
|
||||
? opts.lane
|
||||
: [opts.lane, ...opts.lanePrefixes.map((prefix) => String(prefix).concat("*"))].join(", "),
|
||||
files,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user