Read into pandas dataframe to compute consumed energy
This commit is contained in:
parent
d355d7b348
commit
eeba6f7942
1 changed files with 25 additions and 1 deletions
|
@ -89,6 +89,12 @@ class Power:
|
||||||
|
|
||||||
power = cls.from_list(all_list)
|
power = cls.from_list(all_list)
|
||||||
|
|
||||||
|
power.df = db.db_to_pf(jobid, interval, hawk_ai)
|
||||||
|
# power.df.to_pickle("pickle_df")
|
||||||
|
power.by_node = power.df.groupby('name')
|
||||||
|
power.by_epoch = power.df.groupby('time')
|
||||||
|
power.energy = power.summarize_energy()
|
||||||
|
|
||||||
return power
|
return power
|
||||||
|
|
||||||
def to_file(self, jobid, header=""):
|
def to_file(self, jobid, header=""):
|
||||||
|
@ -99,6 +105,7 @@ class Power:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
header += self.warnings
|
header += self.warnings
|
||||||
|
header += self.energy
|
||||||
try:
|
try:
|
||||||
with open(fname, "w+") as f:
|
with open(fname, "w+") as f:
|
||||||
f.write(header + self.header())
|
f.write(header + self.header())
|
||||||
|
@ -148,6 +155,22 @@ class Power:
|
||||||
+ self.summarize_values(values) \
|
+ self.summarize_values(values) \
|
||||||
+ tuple(values)
|
+ tuple(values)
|
||||||
|
|
||||||
|
def energy_total(self):
|
||||||
|
energy = None
|
||||||
|
if hasattr(self, "by_node"):
|
||||||
|
energy = self.by_node.apply(self.energy_node).sum()
|
||||||
|
return energy
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def energy_node(group):
|
||||||
|
"""Left-sided Riemann sum is enough, as time is lower bound of bucket"""
|
||||||
|
delta_t = group["time"].diff().shift(-1)/1000. # in seconds
|
||||||
|
pow = group["avg"]
|
||||||
|
return (delta_t * pow).iloc[:-1].sum()
|
||||||
|
|
||||||
|
def summarize_energy(self):
|
||||||
|
return "# Total energy consumed by job: {energy:.0f} J\n".format(energy=self.energy_total())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def pretty_print(args):
|
def pretty_print(args):
|
||||||
return ",".join(str(a) for a in args) + '\n'
|
return ",".join(str(a) for a in args) + '\n'
|
||||||
|
@ -252,7 +275,8 @@ class App:
|
||||||
print('Created file {fn}'.format(fn=fn))
|
print('Created file {fn}'.format(fn=fn))
|
||||||
if power.warnings:
|
if power.warnings:
|
||||||
print(power.warnings)
|
print(power.warnings)
|
||||||
|
if power.energy:
|
||||||
|
print(power.energy)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Reference in a new issue