From 1fbb943005ad78335f0b921be516b3df8140406d Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Sun, 4 Jun 2023 18:34:21 +0800 Subject: --- analysis0510.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'analysis0510.py') diff --git a/analysis0510.py b/analysis0510.py index 59cc65c..78290ab 100755 --- a/analysis0510.py +++ b/analysis0510.py @@ -6,7 +6,7 @@ def read_from_line(line: str) -> dict[str, int | float]: ret = {} if 'skip:' in line: ret.update({'skip': int(line.split('skip:', 1)[1].split(',')[0])}) - ret.update({'sample': int(line.split('length:', 1)[1].split('|', 1)[0])}) + ret.update({'sample': int(line.split('length:', 1)[1].split('custom time:', 1)[0])}) ret.update({'custom': float(line.split('custom time: ', 1)[1].split('time')[0])}) ret.update({'normal': float(line.rsplit('time:', 1)[1])}) return ret @@ -30,6 +30,11 @@ def get_array_summary(sz: list[float]) -> tuple[str, str]: return f'{middle:.6f}', f'{avg:.6f}' +def calc_improve(element: list[int]) -> float: + a, b = list(map(float, element[:2])) + return a / b if a > b else b / a + + def read(file: str, need_calc: bool = False, output_latex: bool = False) -> None: items = {} with open(file) as fin: @@ -50,8 +55,9 @@ def read(file: str, need_calc: bool = False, output_latex: bool = False) -> None new_result[key][x].append(element[x]) print(*keys) for key, value in new_result.items(): - column = list(get_array_summary(value[x]) for x in keys) + column = list(get_array_summary(value[x])[1] for x in keys) if output_latex: + column.append(f'{calc_improve(column):.6f}') column = list(map(str, column)) column.insert(0, str(key)) print('\\hline\n', ' & '.join(column), '\\\\') -- cgit v1.3.1