fix: mark missed cpu profile performance windows

This commit is contained in:
Codex
2026-07-02 14:01:57 +00:00
parent c2d3814415
commit 632c557d18
2 changed files with 15 additions and 3 deletions
@@ -798,14 +798,20 @@ function performanceEvidenceMode(perf, commandFiles){
const commands=performanceCaptureCommandStatus(commandFiles);
const runner=runnerStatusForPerformance();
const pendingPerformanceCapture=commands.pendingCount>0||commands.processingCount>0;
const coveredWindowCount=Number(s.cpuProfileWindowCoveredCount??0);
const overlappedWindowCount=Number(s.cpuProfileWindowOverlappedCount??0);
const missedWindowCount=Number(s.cpuProfileWindowMissedCount??0);
const cpuProfileMissedPerformanceWindows=hasCpuProfile&&missedWindowCount>0&&coveredWindowCount===0&&overlappedWindowCount===0;
const cpuProfileStatus=hasCpuProfile?String(s.cpuProfileStatus||'captured'):pendingPerformanceCapture?'pending-command-no-cpu-profile':'no-cpu-profile';
const attributionMode=hasCpuProfile?'cpu-profile-and-performance-observer':hasPerformanceObserverEvidence?'loaf-only-no-cpu-profile':'no-frontend-performance-evidence';
const attributionMode=cpuProfileMissedPerformanceWindows?String(s.attributionMode||'cpu-profile-missed-performance-window'):hasCpuProfile?String(s.attributionMode||'cpu-profile-and-performance-observer'):hasPerformanceObserverEvidence?'loaf-only-no-cpu-profile':'no-frontend-performance-evidence';
const statement=hasCpuProfile
? 'CPU profile artifacts are present; hotspot rows may be used as CPU profile evidence.'
? cpuProfileMissedPerformanceWindows
? 'CPU profile artifacts exist but missed severe performance windows; do not cite CPU profile hotspots as same-window evidence.'
: 'CPU profile artifacts are present; hotspot rows may be used as CPU profile evidence.'
: pendingPerformanceCapture
? 'LoAF-only / no CPU profile: performanceCapture is pending or processing, so CPU profile hotspots are unavailable for this run.'
: 'LoAF-only / no CPU profile: no completed performanceCapture artifact is present, so do not cite CPU profile hotspots.';
return {attributionMode,cpuProfileStatus,hasCpuProfile,noCpuProfile:!hasCpuProfile,loafOnly:!hasCpuProfile&&hasPerformanceObserverEvidence,pendingPerformanceCapture,runner,performanceCaptureCommands:commands,statement,valuesRedacted:true};
return {attributionMode,cpuProfileStatus,hasCpuProfile,noCpuProfile:!hasCpuProfile,loafOnly:!hasCpuProfile&&hasPerformanceObserverEvidence,pendingPerformanceCapture,cpuProfileMissedPerformanceWindows,runner,performanceCaptureCommands:commands,statement,valuesRedacted:true};
}
function performanceSummaryFromReport(){
const perf=report.frontendPerformance&&typeof report.frontendPerformance==='object'?report.frontendPerformance:{};
@@ -250,8 +250,14 @@ test("performance-summary renders CPU profile window misses and source attributi
const output = JSON.parse(result.stdout);
const text = String(output.renderedText ?? "");
const debug = JSON.stringify({ summary: output.summary, evidenceMode: output.evidenceMode, text }, null, 2);
assert.equal(output.summary.cpuProfileWindowMissedCount, 1);
assert.equal(output.evidenceMode.attributionMode, "cpu-profile-missed-performance-window", debug);
assert.equal(output.evidenceMode.cpuProfileMissedPerformanceWindows, true, debug);
assert.match(text, /window correlation=1 covered=0 overlapped=0 missed=1 missing=0 sourceMap=missing/u);
assert.match(text, /evidence attribution=cpu-profile-missed-performance-window/u);
assert.match(text, /CPU profile artifacts exist but missed severe performance windows; do not cite CPU profile hotspots as same-window evidence/u);
assert.doesNotMatch(text, /hotspot rows may be used as CPU profile evidence/u);
assert.match(text, /cpuWindow=missed/u);
assert.match(text, /nearest performanceCapture started after/u);
assert.match(text, /CodeWorkbenchView\.js/u);