perf: diagnoistics improvements
This commit is contained in:
@@ -4,6 +4,10 @@ export interface AppMetricsProcessSnapshot {
|
||||
pid: number;
|
||||
type: string;
|
||||
workingSetKb: number | null;
|
||||
peakWorkingSetKb: number | null;
|
||||
privateBytesKb: number | null;
|
||||
creationTime: number | null;
|
||||
cpuPercent: number | null;
|
||||
}
|
||||
|
||||
export interface AppMetricsSnapshot {
|
||||
@@ -17,7 +21,17 @@ export function collectAppMetricsSnapshot(): AppMetricsSnapshot {
|
||||
processes: app.getAppMetrics().map((metric) => ({
|
||||
pid: metric.pid,
|
||||
type: metric.type,
|
||||
workingSetKb: metric.memory?.workingSetSize ?? null
|
||||
workingSetKb: metric.memory?.workingSetSize ?? null,
|
||||
peakWorkingSetKb: readOptionalKilobytes(metric.memory?.peakWorkingSetSize),
|
||||
privateBytesKb: readOptionalKilobytes(metric.memory?.privateBytes),
|
||||
creationTime: metric.creationTime ?? null,
|
||||
cpuPercent: typeof metric.cpu?.percentCPUUsage === 'number'
|
||||
? Math.round(metric.cpu.percentCPUUsage * 10) / 10
|
||||
: null
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
function readOptionalKilobytes(value: number | undefined): number | null {
|
||||
return typeof value === 'number' && value >= 0 ? value : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user