Skip to content

Commit

Permalink
fix: get energy only in J
Browse files Browse the repository at this point in the history
  • Loading branch information
altor committed Sep 25, 2019
1 parent dae3c01 commit 5b73abd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyRAPL/pyRAPL.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def energy(self, device):
"""
return the amount of consumed energy by the device given in parameter since last CPU reset
:param Device device: the device to get the power consumption
:return int: the amount of consumed energy of the device since last CPU reset in mJ
:return float: the amount of consumed energy of the device since last CPU reset in J
:raise PyRAPLCantRecordEnergyConsumption: if no energy consumtion metric is available for the given device
:raise TypeError: if device is not a Device instance
"""
Expand All @@ -203,7 +203,7 @@ def energy(self, device):

api_file = self._sys_api[device]
api_file.seek(0, 0)
return int(api_file.readline())
return int(api_file.readline())/1000000

def _begin_record(self, device):
energy = self.energy(device)
Expand Down Expand Up @@ -243,7 +243,7 @@ def stop(self):

def _compute_recorded_energy(self, device):

recorded_energy = (self._measure[device][1] - self._measure[device][0])/1000000
recorded_energy = (self._measure[device][1] - self._measure[device][0])
# print("yolo")
self._measure[device][0] = None
self._measure[device][1] = None
Expand All @@ -252,7 +252,7 @@ def _compute_recorded_energy(self, device):
def recorded_energy(self, *devices):
"""
get the latest energy consumption recorded by PyRAPL for the given device
:return: energy (in mJ) consumed between the last record() and stop() function call
:return: energy (in J) consumed between the last record() and stop() function call
:raise PyRAPLNoEnergyConsumptionRecordedException: if no energy consumption was recorded
:raise TypeError: if device is not a Device instance
"""
Expand Down

0 comments on commit 5b73abd

Please sign in to comment.