class pyRAPL.Device

Device that can be monitored by pyRAPL

Device.PKG : to monitor the CPU energy consumption

Device.DRAM : to monitor the RAM energy consumption


pyRAPL.setup(devices=None, socket_ids=None)

Configure which device and CPU socket should be monitored by pyRAPL

This function must be called before using any other pyRAPL functions

  • devices (Optional[List[Device]]) – list of monitored devices if None, all the available devices on the machine will be monitored

  • socket_ids (Optional[List[int]]) – list of monitored sockets, if None, all the available socket on the machine will be monitored



@pyRAPL.measureit(_func=None, *, output=None, number=1)

Measure the energy consumption of monitored devices during the execution of the decorated function (if multiple runs it will measure the mean energy)

  • output (Optional[Output]) – output instance that will receive the power consummation data

  • number (int) – number of iteration in the loop in case you need multiple runs or the code is too fast to be measured


class pyRAPL.Measurement(label, output=None)

measure the energy consumption of devices on a bounded period

Beginning and end of this period are given by calling begin() and end() methods

  • label (str) – measurement label

  • output (Optional[Output]) – default output to export the recorded energy consumption. If None, the PrintOutput will be used


Start energy consumption recording


End energy consumption recording


Export the energy consumption measures to a given output


output (Optional[Output]) – output that will handle the measure, if None, the default output will be used

property result

Access to the measurement data

Return type


class pyRAPL.Result(label, timestamp, duration, pkg=None, dram=None)

A data class to represent the energy measures

  • label (str) – measurement label

  • timestamp (float) – measurement’s beginning time (expressed in seconds since the epoch)

  • duration (float) – measurement’s duration (in micro seconds)

  • pkg (Optional[List[float]]) – list of the CPU energy consumption -expressed in micro Joules- (one value for each socket) if None, no CPU energy consumption was recorded

  • dram (Optional[List[float]]) – list of the RAM energy consumption -expressed in seconds- (one value for each socket) if None, no RAM energy consumption was recorded


exception pyRAPL.PyRAPLException

Parent class of all PyRAPL exception

exception pyRAPL.PyRAPLCantRecordEnergyConsumption(device)

Exception raised when starting recording energy consumption for a device but no energy consumption metric is available for this device


device (Device) – device that couldn’t be monitored (if None, Any device on the machine could be monitored)

exception pyRAPL.PyRAPLBadSocketIdException(socket_id)

Exception raised when trying to initialise PyRAPL on a socket that doesn’t exist on the machine


socket_id (int) – socket that doesn’t exist