IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

CPUMetricsCollector

CPUMetricsCollector​

class max.profiler.cpu.CPUMetricsCollector(pids)

source

Bases: object

Collects aggregate CPU time across a set of PIDs.

Use as a context manager around the workload, then call get_stats() to obtain the CPUMetrics summary.

collector = CPUMetricsCollector(pids)
with collector:
    run_workload()
metrics = collector.get_stats()

Parameters:

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

get_stats()​

get_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 the context manager was not used, or if elapsed time is non-positive.

Return type:

CPUMetrics