write results on failures
This commit is contained in:
parent
ace846991e
commit
e77f46914c
1 changed files with 16 additions and 10 deletions
|
@ -42,9 +42,13 @@ class Cmd:
|
||||||
self.execution_time = None # type: Optional[datetime.timedelta]
|
self.execution_time = None # type: Optional[datetime.timedelta]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_title(self):
|
def has_title(self) -> bool:
|
||||||
return self.title is not None
|
return self.title is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def was_executed(self) -> bool:
|
||||||
|
return self.execution_time is not None
|
||||||
|
|
||||||
|
|
||||||
class Remove(Cmd):
|
class Remove(Cmd):
|
||||||
"""Remove command, sensitive to OS."""
|
"""Remove command, sensitive to OS."""
|
||||||
|
@ -86,12 +90,14 @@ def run_benchmark(commit: str, name: str, result_file_path: str, workdir: str, p
|
||||||
if os.path.exists(workdir):
|
if os.path.exists(workdir):
|
||||||
run_cmd(Remove(workdir), cmd_parameters, '.')
|
run_cmd(Remove(workdir), cmd_parameters, '.')
|
||||||
os.makedirs(workdir)
|
os.makedirs(workdir)
|
||||||
for command in COMMANDS:
|
try:
|
||||||
run_cmd(command, cmd_parameters, workdir)
|
for command in COMMANDS:
|
||||||
write_results(COMMANDS, result_file_path, name)
|
run_cmd(command, cmd_parameters, workdir)
|
||||||
|
finally:
|
||||||
|
write_results(COMMANDS, result_file_path, name)
|
||||||
|
|
||||||
|
|
||||||
def write_results(commands: List[Cmd], result_file_path : str, name: str):
|
def write_results(commands: List[Cmd], result_file_path: str, name: str):
|
||||||
fieldnames = ['name', 'cores', 'CPU', 'RAM', 'timestamp', 'OS']
|
fieldnames = ['name', 'cores', 'CPU', 'RAM', 'timestamp', 'OS']
|
||||||
fieldnames.extend(cmd.title for cmd in COMMANDS if cmd.has_title)
|
fieldnames.extend(cmd.title for cmd in COMMANDS if cmd.has_title)
|
||||||
exists = os.path.exists(result_file_path)
|
exists = os.path.exists(result_file_path)
|
||||||
|
@ -102,12 +108,12 @@ def write_results(commands: List[Cmd], result_file_path : str, name: str):
|
||||||
row = {
|
row = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'cores': multiprocessing.cpu_count(),
|
'cores': multiprocessing.cpu_count(),
|
||||||
'CPU' : platform.processor(),
|
'CPU': platform.processor(),
|
||||||
'RAM' : psutil.virtual_memory().total,
|
'RAM': psutil.virtual_memory().total,
|
||||||
'timestamp' : datetime.datetime.now().timestamp(),
|
'timestamp': datetime.datetime.now().timestamp(),
|
||||||
'OS' : platform.platform()
|
'OS': platform.platform()
|
||||||
}
|
}
|
||||||
for command in (cmd for cmd in commands if cmd.has_title):
|
for command in (cmd for cmd in commands if (cmd.has_title and cmd.was_executed)):
|
||||||
row[command.title] = command.execution_time.total_seconds()
|
row[command.title] = command.execution_time.total_seconds()
|
||||||
writer.writerow(row)
|
writer.writerow(row)
|
||||||
print('Benchmark completed.')
|
print('Benchmark completed.')
|
||||||
|
|
Loading…
Reference in a new issue