Skip to content

Commit

Permalink
comments and total power computation with start and end
Browse files Browse the repository at this point in the history
  • Loading branch information
sekkariaamer12 committed Oct 20, 2023
1 parent a03ac88 commit 41ca7ef
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions deep_learning_power_measure/power_measure/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def get_usage_duration(curve):

def total(metric: list, start=None, end=None):
"""Return the integration over time for the metric. For instance if the metric is in watt and the time in seconds,
the return value is the energy consumed in Joules"""
the return value is the energy consumed in Joules
Input:
- list a list containing different segments, each segment is a list where one item is a dictionnary with keys 'date' and 'value'f_____
"""
if isinstance(metric, list):
rs = [ integrate(segment,start=start,end=end) for segment in metric ]
if rs[0] is not None:
Expand Down Expand Up @@ -622,10 +625,10 @@ def max_(self, metric_name: str, start=None, end=None):
#max([m["value"] for segment in mtrc for m in segment])
return maxs

def total_power_draw(self):
def total_power_draw(self,start=None, end=None):
"""extracting cpu and GPU power draw for the whole machine"""
total_intel_power = self.total_('intel_power')
abs_nvidia_power = self.total_('nvidia_draw_absolute')
total_intel_power = self.total_('intel_power',start=start, end=end)
abs_nvidia_power = self.total_('nvidia_draw_absolute',start=start, end=end)
return total_intel_power + abs_nvidia_power

def display_curves(self, metric_names, saveto=None):
Expand Down Expand Up @@ -703,17 +706,17 @@ def __str__(self) -> str:
r = ['Available metrics : ']
r.append('CPU')
if self.cpu_metrics is not None:
r.append(' '+','.join([k for k in self.cpu_metrics.keys()]))
r.append(' '+', '.join([k for k in self.cpu_metrics.keys()]))
else:
r.append('NOT AVAILABLE')
r.append('GPU')
if self.gpu_metrics is not None:
r.append(' '+','.join([k for k in self.gpu_metrics.keys()]))
r.append(' '+', '.join([k for k in self.gpu_metrics.keys()]))
else:
r.append('NOT AVAILABLE')
r.append('Experiments')
if self.gpu_metrics is not None:
r.append(' '+','.join([k for k in self.gpu_metrics.keys()]))
if self.exp_metrics is not None:
r.append(' '+', '.join([k for k in self.exp_metrics.keys()]))
else:
r.append('NOT AVAILABLE')
r.append('\n\ncall print() method to display power consumption')
Expand All @@ -740,7 +743,8 @@ def get_summary(self, start=None, end=None):
summary['cpu']['mem_use_abs'] = self.average_('per_process_mem_use_abs',start=start, end=end)
summary['cpu']['mem_use_uss'] = self.average_('per_process_mem_use_uss',start=start, end=end)
summary['cpu']['absolute_cpu_time_per_pid'] = self.total_('absolute_cpu_time_per_pid',start=start, end=end)
summary['cpu']['average_cpu_use'] = self.average_('per_process_cpu_uses',start=start, end=end)
summary['cpu']['relative_cpu_use'] = self.average_('per_process_cpu_uses',start=start, end=end)

if self.gpu_metrics is not None:
summary['gpu'] = {}
summary['gpu']['abs_nvidia_power'] = self.total_('nvidia_draw_absolute',start=start, end=end)
Expand Down

0 comments on commit 41ca7ef

Please sign in to comment.