Skip to content
Snippets Groups Projects
Commit bcedc988 authored by Martin Sauter's avatar Martin Sauter
Browse files

* refactored get_cpu_efficiency

parent 6f028ec1
Branches
No related tags found
No related merge requests found
......@@ -148,18 +148,16 @@ class EvaluateMonitoring:
self.df['waiting_time'] = self.df['Finish'] - self.df['timestamp'] - self.df['Runtime']
except Exception as e:
print("Python-Error: " + str(e) + "\nFailed to calculate waiting time!")
exit(-1)
def get_cpu_efficiency(self):
self.df['cpu_efficiency'] = 0.0
for index, row in self.df.iterrows():
try:
if float(row['RemoteUserCpu']) > 0.0 and float(row['RemoteSysCpu']) > 0.0:
self.df.at[index, 'cpu_efficiency'] = (float(row['RemoteUserCpu']) + float(row['RemoteSysCpu']))\
/ (float(row['Runtime']) * float(row['RequestCpus'])) * 100
else:
self.df.at[index, 'cpu_efficiency'] = np.nan
except Exception as e:
print("Python-Error: " + str(e) + "\nFailed to calculate cpu efficiency for index: " + str(index))
try:
self.df['cpu_efficiency'] = np.where(((self.df['RemoteUserCpu'] > 0.0) & (self.df['RemoteSysCpu'] > 0.0)),
((self.df['RemoteUserCpu'] + self.df['RemoteSysCpu']) /
(self.df['Runtime'] * self.df['RequestCpus']) * 100), np.nan)
except Exception as e:
print("Python-Error: " + str(e) + "\nFailed to calculate cpu efficiency!")
exit(-1)
def get_file_duplicity_stat(self):
start = time()
......@@ -181,17 +179,3 @@ class EvaluateMonitoring:
index += 1
print('Duplicity calculation time: ', time()-start)
# def get_file_duplicity_stat(self):
# start=time()
# self.df_file['timestamp'] = np.nan
# for index, row in self.df.iterrows():
# self.df_file.at[index, 'timestamp'] = float(row['timestamp'])
# requested_files = eval(str(row['files_found_on_server']))
# for key, value in iter(requested_files.items()):
# if key not in self.df_file.columns:
# self.df_file.at[index, key] = np.nan
# if value[0] == 'No server':
# self.df_file.at[index, key] = 0
# else:
# self.df_file.at[index, key] = len(value)
# print('Duplicity calculation time: ',time()-start)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment