TimingsCollector#

class ansys.fluent.mcp.common.timings.TimingsCollector#

Process-wide singleton. Thread-safe. No async is required.

Overview#

record

Record timing information for an operation.

time

Context manager: with timings.time('tool', name): ....

snapshot

Return a JSON-friendly view, sorted by the total_ms description per scope.

summary

One row per scope with totals, providing a cheap top-line metric.

uptime_s

Return process uptime in seconds.

reset

Reset collected timing information.

Import detail#

from ansys.fluent.mcp.common.timings import TimingsCollector

Method detail#

TimingsCollector.record(scope: str, key: str, elapsed_ms: float, *, errored: bool = False) None#

Record timing information for an operation.

Parameters:
scopestr

Scope to supply to the function.

keystr

Key for looking up or storing the associated value.

elapsed_msfloat

Elapsed milliseconds to supply to the function.

erroredbool

Whether to enable or apply errored.

Returns:
None

The function completes through its side effects.

TimingsCollector.time(scope: str, key: str) Iterator[None]#

Context manager: with timings.time('tool', name): ....

Parameters:
scopestr

Scope to limit the field or API lookup.

keystr

Key to supply to the function.

Returns:
Iterator[None]

Result produced by the function.

TimingsCollector.snapshot() dict[str, list[dict[str, float | int | str]]]#

Return a JSON-friendly view, sorted by the total_ms description per scope.

This approach ensures the slow paths sit at the top.

Returns:
dict[str, list[dict[str, float | int | str]]]

Mapping containing the operation result.

TimingsCollector.summary() dict[str, dict[str, float | int]]#

One row per scope with totals, providing a cheap top-line metric.

Returns:
dict[str, dict[str, float | int]]

Mapping containing the operation result.

TimingsCollector.uptime_s() float#

Return process uptime in seconds.

Returns:
float

Floating-point result produced by the operation.

TimingsCollector.reset() None#

Reset collected timing information.

Returns:
None

The function completes through its side effects.