mendevi.measures.rapl

Try to read the energy with RAPL.

Classes

RAPL([sleep, no_fail])

Uses the linux perf command through a python context manager.

Details

class mendevi.measures.rapl.RAPL(sleep: Real = 0.05, *, no_fail: bool = False)[source]

Uses the linux perf command through a python context manager.

Examples

>>> import time
>>> from mendevi.measures.rapl import RAPL
>>> with RAPL() as energy:
...     time.sleep(1)
...
>>>

Init the perf context.

Parameters

sleepfloat, default=50e-3

The time interval between 2 measures (in s).

no_failbool, default=True

If False, raise RuntimeError if it fails to get the RAPL measure. Otherwise (if True), return None instead of failing.