fix: ensure summary stats reflect inclusive usage in targeted mode

This commit is contained in:
2026-02-23 18:33:43 +01:00
parent 1663c3702e
commit 34aac2da62

View File

@@ -470,10 +470,17 @@ function ReportView({ report, onBack }: { report: ProfilingReport, onBack: () =>
}, [report, hideProfiler]); }, [report, hideProfiler]);
const summaryStats = useMemo(() => { const summaryStats = useMemo(() => {
if (report.mode === ProfilingMode.Targeted) {
// In targeted mode, the root of sortedProcesses is our target
const root = sortedProcesses[0];
if (root) {
return { cpu: root.inclusive_avg_cpu, mem: root.inclusive_avg_memory_mb };
}
}
const totalCpu = sortedProcesses.reduce((acc, p) => acc + p.avg_cpu, 0); const totalCpu = sortedProcesses.reduce((acc, p) => acc + p.avg_cpu, 0);
const totalMem = sortedProcesses.reduce((acc, p) => acc + p.avg_memory_mb, 0); const totalMem = sortedProcesses.reduce((acc, p) => acc + p.avg_memory_mb, 0);
return { cpu: totalCpu, mem: totalMem }; return { cpu: totalCpu, mem: totalMem };
}, [sortedProcesses]); }, [sortedProcesses, report.mode]);
const saveReport = async () => { const saveReport = async () => {
try { try {