mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 08:10:48 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
74
openclaw/scripts/test-perf-budget.mjs
Normal file
74
openclaw/scripts/test-perf-budget.mjs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { floatFlag, parseFlagArgs, readEnvNumber, stringFlag } from "./lib/arg-utils.mjs";
|
||||
import { formatMs } from "./lib/vitest-report-cli-utils.mjs";
|
||||
import { readJsonFile, runVitestJsonReport } from "./test-report-utils.mjs";
|
||||
|
||||
function parseArgs(argv) {
|
||||
return parseFlagArgs(
|
||||
argv,
|
||||
{
|
||||
config: "test/vitest/vitest.unit.config.ts",
|
||||
maxWallMs: readEnvNumber("OPENCLAW_TEST_PERF_MAX_WALL_MS"),
|
||||
baselineWallMs: readEnvNumber("OPENCLAW_TEST_PERF_BASELINE_WALL_MS"),
|
||||
maxRegressionPct: readEnvNumber("OPENCLAW_TEST_PERF_MAX_REGRESSION_PCT") ?? 10,
|
||||
},
|
||||
[
|
||||
stringFlag("--config", "config"),
|
||||
floatFlag("--max-wall-ms", "maxWallMs"),
|
||||
floatFlag("--baseline-wall-ms", "baselineWallMs"),
|
||||
floatFlag("--max-regression-pct", "maxRegressionPct"),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
const opts = parseArgs(process.argv.slice(2));
|
||||
const startedAt = process.hrtime.bigint();
|
||||
const reportPath = runVitestJsonReport({
|
||||
config: opts.config,
|
||||
prefix: "openclaw-vitest-perf",
|
||||
});
|
||||
const elapsedMs = Number(process.hrtime.bigint() - startedAt) / 1_000_000;
|
||||
|
||||
let totalFileDurationMs = 0;
|
||||
let fileCount = 0;
|
||||
try {
|
||||
const report = readJsonFile(reportPath);
|
||||
for (const result of report.testResults ?? []) {
|
||||
if (typeof result.startTime === "number" && typeof result.endTime === "number") {
|
||||
totalFileDurationMs += Math.max(0, result.endTime - result.startTime);
|
||||
fileCount += 1;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Keep budget checks based on wall time when JSON parsing fails.
|
||||
}
|
||||
|
||||
const allowedByBaseline =
|
||||
opts.baselineWallMs !== null
|
||||
? opts.baselineWallMs * (1 + (opts.maxRegressionPct ?? 0) / 100)
|
||||
: null;
|
||||
|
||||
let failed = false;
|
||||
if (opts.maxWallMs !== null && elapsedMs > opts.maxWallMs) {
|
||||
console.error(
|
||||
`[test-perf-budget] wall time ${formatMs(elapsedMs)} exceeded max ${formatMs(opts.maxWallMs)}.`,
|
||||
);
|
||||
failed = true;
|
||||
}
|
||||
if (allowedByBaseline !== null && elapsedMs > allowedByBaseline) {
|
||||
console.error(
|
||||
`[test-perf-budget] wall time ${formatMs(elapsedMs)} exceeded baseline budget ${formatMs(
|
||||
allowedByBaseline,
|
||||
)} (baseline ${formatMs(opts.baselineWallMs ?? 0)}, +${String(opts.maxRegressionPct)}%).`,
|
||||
);
|
||||
failed = true;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[test-perf-budget] config=${opts.config} wall=${formatMs(elapsedMs)} file-sum=${formatMs(
|
||||
totalFileDurationMs,
|
||||
)} files=${String(fileCount)}`,
|
||||
);
|
||||
|
||||
if (failed) {
|
||||
process.exit(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue