Skip to content

Commit b35e4b7

Browse files
committed
refactor formatting and improve clarity in performance table generation
1 parent 20b8f1b commit b35e4b7

File tree

2 files changed

+55
-19
lines changed

2 files changed

+55
-19
lines changed

scoreboard/main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,19 +676,29 @@ def _compute_display_deadlines_processes(n_items: int) -> list[date]:
676676

677677
# Locate perf CSVs from CI or local runs (threads and processes)
678678
candidates_threads = [
679-
script_dir.parent / "build" / "perf_stat_dir" / "threads_task_run_perf_table.csv",
679+
script_dir.parent
680+
/ "build"
681+
/ "perf_stat_dir"
682+
/ "threads_task_run_perf_table.csv",
680683
script_dir.parent / "perf_stat_dir" / "threads_task_run_perf_table.csv",
681684
# Fallback to old single-file name
682685
script_dir.parent / "build" / "perf_stat_dir" / "task_run_perf_table.csv",
683686
script_dir.parent / "perf_stat_dir" / "task_run_perf_table.csv",
684687
]
685-
threads_csv = next((p for p in candidates_threads if p.exists()), candidates_threads[0])
688+
threads_csv = next(
689+
(p for p in candidates_threads if p.exists()), candidates_threads[0]
690+
)
686691

687692
candidates_processes = [
688-
script_dir.parent / "build" / "perf_stat_dir" / "processes_task_run_perf_table.csv",
693+
script_dir.parent
694+
/ "build"
695+
/ "perf_stat_dir"
696+
/ "processes_task_run_perf_table.csv",
689697
script_dir.parent / "perf_stat_dir" / "processes_task_run_perf_table.csv",
690698
]
691-
processes_csv = next((p for p in candidates_processes if p.exists()), candidates_processes[0])
699+
processes_csv = next(
700+
(p for p in candidates_processes if p.exists()), candidates_processes[0]
701+
)
692702

693703
# Read and merge performance statistics CSVs
694704
perf_stats_threads = load_performance_data_threads(threads_csv)

scripts/create_perf_table.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,19 @@ def _infer_category(task_name: str) -> str:
3636

3737

3838
def _columns_for_category(category: str) -> list[str]:
39-
return ["seq", "omp", "tbb", "stl", "all"] if category == "threads" else ["seq", "mpi"]
40-
41-
42-
def _write_excel_sheet(workbook, worksheet, cpu_num: int, tasks_list: list[str], cols: list[str], table: dict):
39+
return (
40+
["seq", "omp", "tbb", "stl", "all"] if category == "threads" else ["seq", "mpi"]
41+
)
42+
43+
44+
def _write_excel_sheet(
45+
workbook,
46+
worksheet,
47+
cpu_num: int,
48+
tasks_list: list[str],
49+
cols: list[str],
50+
table: dict,
51+
):
4352
worksheet.set_column("A:Z", 23)
4453
right_bold_border = workbook.add_format({"bold": True, "right": 2, "bottom": 2})
4554
bottom_bold_border = workbook.add_format({"bold": True, "bottom": 2})
@@ -59,13 +68,17 @@ def _write_excel_sheet(workbook, worksheet, cpu_num: int, tasks_list: list[str],
5968
bottom_bold_border,
6069
)
6170
col += 1
62-
worksheet.write(0, col, f"Eff({cpu_num}) = S({cpu_num}) / {cpu_num}", right_bold_border)
71+
worksheet.write(
72+
0, col, f"Eff({cpu_num}) = S({cpu_num}) / {cpu_num}", right_bold_border
73+
)
6374
col += 1
6475

6576
# Task rows
6677
row = 1
6778
for task_name in tasks_list:
68-
worksheet.write(row, 0, task_name, workbook.add_format({"bold": True, "right": 2}))
79+
worksheet.write(
80+
row, 0, task_name, workbook.add_format({"bold": True, "right": 2})
81+
)
6982
row += 1
7083

7184
# Values
@@ -75,9 +88,12 @@ def _write_excel_sheet(workbook, worksheet, cpu_num: int, tasks_list: list[str],
7588
for ttype in cols:
7689
if task_name not in table:
7790
# no data for task at all
78-
worksheet.write(row, col, "—"); col += 1
79-
worksheet.write(row, col, "—"); col += 1
80-
worksheet.write(row, col, "—", right_border); col += 1
91+
worksheet.write(row, col, "—")
92+
col += 1
93+
worksheet.write(row, col, "—")
94+
col += 1
95+
worksheet.write(row, col, "—", right_border)
96+
col += 1
8197
continue
8298
par_time = table[task_name].get(ttype, -1.0)
8399
seq_time = table[task_name].get("seq", -1.0)
@@ -87,9 +103,12 @@ def _write_excel_sheet(workbook, worksheet, cpu_num: int, tasks_list: list[str],
87103
else:
88104
speed_up = seq_time / par_time
89105
efficiency = speed_up / cpu_num
90-
worksheet.write(row, col, par_time if par_time != -1.0 else "?"); col += 1
91-
worksheet.write(row, col, speed_up); col += 1
92-
worksheet.write(row, col, efficiency, right_border); col += 1
106+
worksheet.write(row, col, par_time if par_time != -1.0 else "?")
107+
col += 1
108+
worksheet.write(row, col, speed_up)
109+
col += 1
110+
worksheet.write(row, col, efficiency, right_border)
111+
col += 1
93112
row += 1
94113

95114

@@ -109,6 +128,7 @@ def _write_csv(path: str, header: list[str], tasks_list: list[str], table: dict)
109128
row.append(val / seq_time if val != -1.0 else "?")
110129
writer.writerow(row)
111130

131+
112132
parser = argparse.ArgumentParser()
113133
parser.add_argument(
114134
"-i", "--input", help="Input file path (logs of perf tests, .txt)", required=True
@@ -236,18 +256,24 @@ def _write_csv(path: str, header: list[str], tasks_list: list[str], table: dict)
236256

237257
cpu_num_env = os.environ.get("PPC_NUM_PROC")
238258
if cpu_num_env is None:
239-
raise EnvironmentError("Required environment variable 'PPC_NUM_PROC' is not set.")
259+
raise EnvironmentError(
260+
"Required environment variable 'PPC_NUM_PROC' is not set."
261+
)
240262
cpu_num = int(cpu_num_env)
241263
cols = _columns_for_category(category)
242264

243265
# Excel
244-
wb_path = os.path.join(xlsx_path, f"{category}_" + table_name + "_perf_table.xlsx")
266+
wb_path = os.path.join(
267+
xlsx_path, f"{category}_" + table_name + "_perf_table.xlsx"
268+
)
245269
workbook = xlsxwriter.Workbook(wb_path)
246270
worksheet = workbook.add_worksheet()
247271
_write_excel_sheet(workbook, worksheet, cpu_num, tasks_list, cols, table_data)
248272
workbook.close()
249273

250274
# CSV
251275
header = ["Task", "SEQ"] + [c.upper() for c in cols[1:]]
252-
csv_path = os.path.join(xlsx_path, f"{category}_" + table_name + "_perf_table.csv")
276+
csv_path = os.path.join(
277+
xlsx_path, f"{category}_" + table_name + "_perf_table.csv"
278+
)
253279
_write_csv(csv_path, header, tasks_list, table_data)

0 commit comments

Comments
 (0)