Skip to content

Commit 9540525

Browse files
authored
[scoreboard] Add efficiency and deadline scoring (#539)
- extend config with efficiency parameters and deadlines - compute efficiency and deadline penalties in scoreboard - show them in the HTML template
1 parent 4240da3 commit 9540525

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

scoreboard/data/threads-config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ scoreboard:
3838
visible: true
3939
plagiarism:
4040
coefficient: 0.5
41+
efficiency:
42+
num_proc: 4
43+
deadlines:
44+
mpi: "2025-12-31"
45+
omp: "2025-12-31"
46+
seq: "2025-12-31"
47+
stl: "2025-12-31"
48+
tbb: "2025-12-31"
49+
all: "2025-12-31"

scoreboard/main.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from pathlib import Path
22
from collections import defaultdict
3+
from datetime import datetime
34
import argparse
5+
import subprocess
46
import yaml
57
import csv
68
from jinja2 import Environment, FileSystemLoader
@@ -29,6 +31,8 @@
2931
with open(config_path, "r") as file:
3032
cfg = yaml.safe_load(file)
3133
assert cfg, "Configuration is empty"
34+
eff_num_proc = int(cfg["scoreboard"].get("efficiency", {}).get("num_proc", 1))
35+
deadlines_cfg = cfg["scoreboard"].get("deadlines", {})
3236
plagiarism_config_path = Path(__file__).parent / "data" / "plagiarism.yml"
3337
with open(plagiarism_config_path, "r") as file:
3438
plagiarism_cfg = yaml.safe_load(file)
@@ -85,11 +89,45 @@
8589

8690
perf_val = perf_stats.get(dir, {}).get(task_type, "?")
8791

92+
# Calculate efficiency if performance data is available
93+
efficiency = "?"
94+
try:
95+
perf_float = float(perf_val)
96+
if perf_float > 0:
97+
speedup = 1.0 / perf_float
98+
efficiency = f"{speedup / eff_num_proc * 100:.2f}"
99+
except (ValueError, TypeError):
100+
pass
101+
102+
# Calculate deadline penalty points
103+
deadline_points = 0
104+
deadline_str = deadlines_cfg.get(task_type)
105+
if status == "done" and deadline_str:
106+
try:
107+
deadline_dt = datetime.fromisoformat(deadline_str)
108+
git_cmd = [
109+
"git",
110+
"log",
111+
"-1",
112+
"--format=%ct",
113+
str(tasks_dir / (dir + ("_disabled" if status == "disabled" else "")) / task_type),
114+
]
115+
result = subprocess.run(git_cmd, capture_output=True, text=True)
116+
if result.stdout.strip().isdigit():
117+
commit_dt = datetime.fromtimestamp(int(result.stdout.strip()))
118+
days_late = (commit_dt - deadline_dt).days
119+
if days_late > 0:
120+
deadline_points = -days_late
121+
except Exception:
122+
pass
123+
88124
row_types.append(
89125
{
90126
"solution_points": sol_points,
91127
"solution_style": solution_style,
92128
"perf": perf_val,
129+
"efficiency": efficiency,
130+
"deadline_points": deadline_points,
93131
"plagiarised": is_cheated,
94132
"plagiarism_points": plagiarism_points,
95133
}

scoreboard/templates/index.html.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
{% for cell in row.types %}
3838
<td style="text-align: center{% if cell.solution_style %};{{ cell.solution_style }}{% endif %}">{{ cell.solution_points }}</td>
3939
<td style="text-align: center;background-color: lavender;">{{ cell.perf }}</td>
40-
<td style="text-align: center;background-color: lavender;">0</td>
41-
<td style="text-align: center;">0</td>
40+
<td style="text-align: center;background-color: lavender;">{{ cell.efficiency }}</td>
41+
<td style="text-align: center;">{{ cell.deadline_points }}</td>
4242
<td style="text-align: center{% if cell.plagiarised %}; background-color: pink{% endif %}">{{ cell.plagiarism_points }}</td>
4343
{% endfor %}
4444
<td style="text-align: center;">{{ row.total }}</td>

0 commit comments

Comments
 (0)