Skip to main content

Python class

CPUMetricsCollector

CPUMetricsCollector​

class max.diagnostics.cpu.CPUMetricsCollector(pids)

source

Bases: object

Collects aggregate CPU time across a set of PIDs.

Call start() before the workload, stop() after, then dump_stats() to obtain the CPUMetrics summary.

Parameters:

pids (list[int]) – The PIDs of the processes to collect CPU times from.

dump_stats()​

dump_stats()

source

Computes and returns CPU metrics aggregated across the tracked PIDs.

Returns:

The aggregated user and system CPU times along with their utilization percentages over the elapsed wall-clock interval.

Raises:

RuntimeError – If start() and stop() were not called, or if elapsed time is non-positive.

Return type:

CPUMetrics

start()​

start()

source

Records the start clock and per-PID CPU times.

Processes that no longer exist record None and are skipped in dump_stats().

Return type:

None

stop()​

stop()

source

Records the stop clock and per-PID CPU times.

Processes that no longer exist record None and are skipped in dump_stats().

Return type:

None