1
0
Fork 0

added remove steps

This commit is contained in:
Christian Kühnel 2020-03-25 09:25:50 +00:00
parent c0879efea1
commit cc3a1ffb57

View file

@ -22,6 +22,7 @@ import argparse
import csv import csv
import datetime import datetime
import os import os
import platform
import shutil import shutil
import subprocess import subprocess
import sys import sys
@ -39,6 +40,21 @@ class Cmd:
self.title = title # type: Optional[str] self.title = title # type: Optional[str]
self.execution_time = None # type: Optional[datetime.timedelta] self.execution_time = None # type: Optional[datetime.timedelta]
@property
def has_title(self):
return self.title is None
class Remove(Cmd):
"""Remove command, sensitive to OS."""
def __init__(self, path: str):
if platform.system() == 'Windows':
cmd = 'cmd /c rd /s/q {}'.format(path)
else:
cmd = 'rm -rf {}'.format(path)
super().__init__(cmd, "rm -rf {}".format(path))
# commands for the benchmark # commands for the benchmark
COMMANDS = [ COMMANDS = [
@ -48,8 +64,10 @@ COMMANDS = [
Cmd('git pull', 'git pull'), Cmd('git pull', 'git pull'),
Cmd('{pmt_root_path}/scripts/run_cmake.py detect', 'cmake autotdetect'), Cmd('{pmt_root_path}/scripts/run_cmake.py detect', 'cmake autotdetect'),
Cmd('{pmt_root_path}/scripts/run_ninja.py all', 'ninja all 1st'), Cmd('{pmt_root_path}/scripts/run_ninja.py all', 'ninja all 1st'),
Remove('build'),
Cmd('{pmt_root_path}/scripts/run_ninja.py all', 'ninja all 2nd'), Cmd('{pmt_root_path}/scripts/run_ninja.py all', 'ninja all 2nd'),
Cmd('{pmt_root_path}/scripts/run_ninja.py check-all', 'ninja check-all 1st'), Cmd('{pmt_root_path}/scripts/run_ninja.py check-all', 'ninja check-all 1st'),
Remove('build'),
Cmd('{pmt_root_path}/scripts/run_ninja.py check-all', 'ninja check-all 2nd'), Cmd('{pmt_root_path}/scripts/run_ninja.py check-all', 'ninja check-all 2nd'),
] ]
@ -72,7 +90,7 @@ def run_benchmark(commit: str, name: str, result_file_path: str, workdir: str, p
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'] fieldnames = ['name']
fieldnames.extend([cmd.title for cmd in COMMANDS if cmd.title is not None]) 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)
with open(result_file_path, 'a') as csv_file: with open(result_file_path, 'a') as csv_file:
writer = csv.DictWriter(csv_file, fieldnames=fieldnames, dialect=csv.excel) writer = csv.DictWriter(csv_file, fieldnames=fieldnames, dialect=csv.excel)
@ -81,7 +99,7 @@ def write_results(commands: List[Cmd], result_file_path : str, name: str):
row = { row = {
'name': name 'name': name
} }
for command in commands: for command in (cmd for cmd in commands if cmd.has_title):
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.')