API

Enumeration

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

Functions

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

Parameters
  • 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

Raises

Decorator

@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)

Parameters
  • 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

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

Parameters
  • label (str) – measurement label

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

begin()

Start energy consumption recording

end()

End energy consumption recording

export(output=None)

Export the energy consumption measures to a given output

Parameters

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

Result

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

A data class to represent the energy measures

Variables
  • 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

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

Variables

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

Variables

socket_id (int) – socket that doesn’t exist