Skip to content

Commit 277dbb2

Browse files
committed
Add efficiency and deadline scoring
1 parent 3a2a1df commit 277dbb2

3 files changed

Lines changed: 49 additions & 2 deletions

File tree

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)
@@ -83,11 +87,45 @@
8387

8488
perf_val = perf_stats.get(dir, {}).get(task_type, "?")
8589

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

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)