fix(qa): require exact benchmark RSS samples · openclaw/openclaw@5a251bc
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -108,8 +108,14 @@ function listChangedPaths(opts) {
|
108 | 108 | } |
109 | 109 | |
110 | 110 | export function parseMaxRssBytes(output) { |
111 | | -const match = output.match(/(\d+)\s+maximum resident set size/u); |
112 | | -return match ? Number.parseInt(match[1], 10) : null; |
| 111 | +const match = output.match( |
| 112 | +/(?:^|\n)[^\S\r\n]*(\d+)[^\S\r\n]+maximum resident set size[^\S\r\n]*(?:\r?\n|$)/u, |
| 113 | +); |
| 114 | +if (!match) { |
| 115 | +return null; |
| 116 | +} |
| 117 | +const parsed = Number(match[1]); |
| 118 | +return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : null; |
113 | 119 | } |
114 | 120 | |
115 | 121 | export function formatRss(valueBytes) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,9 @@ function runBenchTestChanged(args: string[]) {
|
17 | 17 | describe("bench-test-changed script", () => { |
18 | 18 | it("formats macOS time RSS bytes as MiB", () => { |
19 | 19 | expect(parseMaxRssBytes(" 2097152 maximum resident set size\n")).toBe(2_097_152); |
| 20 | +expect(parseMaxRssBytes(" 2097152kb maximum resident set size\n")).toBeNull(); |
| 21 | +expect(parseMaxRssBytes(" 9007199254740993 maximum resident set size\n")).toBeNull(); |
| 22 | +expect(parseMaxRssBytes("2097152\nmaximum resident set size\n")).toBeNull(); |
20 | 23 | expect(formatRss(2_097_152)).toBe("2.0MB"); |
21 | 24 | expect(formatRss(-1_048_576)).toBe("-1.0MB"); |
22 | 25 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。