mirror of
https://github.com/millionco/react-doctor.git
synced 2026-09-14 20:00:24 +08:00
da3ebf57a2
- scripts/performance/corpus.json + performance:corpus (fetch-corpus.ts) pin the benchmark repos into .performance/corpus; pnpm performance --corpus <names> selects them - REACT_DOCTOR_OXLINT_SPAWN_LOG (off by default) makes spawn-oxlint.ts append one JSON line per oxlint child plus parent CPU at exit; the harness turns it into a scan timeline (procs, failed waves, sum of child durations, avg/peak concurrency, head, tail) - --rule-timings aggregates REACT_DOCTOR_RULE_TIMINGS_DIR output into ranked rule and selector tables; --profile merges child .cpuprofile files into top-40 function and source-URL tables with a plugin/oxlint/gc/node split - --compare reports a speedup ratio per target and flags diagnostics-hash mismatches; --strict exits non-zero on a mismatch - bash time -p fallback when GNU /usr/bin/time is missing so user/sys CPU is always recorded Co-Authored-By: aiden@million.dev <aiden.bai05@gmail.com>
27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
import { BYTES_PER_KIBIBYTE } from "./constants.ts";
|
|
import type { ProcessResourceUsage } from "./types.ts";
|
|
|
|
export const parseProcessResourceUsage = (stderr: string): ProcessResourceUsage => {
|
|
const darwinTimingMatch = stderr.match(/([\d.]+)\s+real\s+([\d.]+)\s+user\s+([\d.]+)\s+sys/);
|
|
const darwinResidentSetMatch = stderr.match(/(\d+)\s+maximum resident set size/);
|
|
const linuxUserMatch = stderr.match(/User time \(seconds\):\s*([\d.]+)/);
|
|
const linuxSystemMatch = stderr.match(/System time \(seconds\):\s*([\d.]+)/);
|
|
const linuxResidentSetMatch = stderr.match(/Maximum resident set size \(kbytes\):\s*(\d+)/);
|
|
const posixUserMatch = stderr.match(/^user\s+([\d.]+)/m);
|
|
const posixSystemMatch = stderr.match(/^sys\s+([\d.]+)/m);
|
|
const userSecondsText = darwinTimingMatch?.[2] ?? linuxUserMatch?.[1] ?? posixUserMatch?.[1];
|
|
const systemSecondsText =
|
|
darwinTimingMatch?.[3] ?? linuxSystemMatch?.[1] ?? posixSystemMatch?.[1];
|
|
let maximumResidentSetBytes: number | null = null;
|
|
if (darwinResidentSetMatch) {
|
|
maximumResidentSetBytes = Number(darwinResidentSetMatch[1]);
|
|
} else if (linuxResidentSetMatch) {
|
|
maximumResidentSetBytes = Number(linuxResidentSetMatch[1]) * BYTES_PER_KIBIBYTE;
|
|
}
|
|
return {
|
|
userSeconds: userSecondsText === undefined ? null : Number(userSecondsText),
|
|
systemSeconds: systemSecondsText === undefined ? null : Number(systemSecondsText),
|
|
maximumResidentSetBytes,
|
|
};
|
|
};
|