From 277dbb2d4d29a293dc2c5e9a3c532cc5b1561802 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Sun, 20 Jul 2025 01:26:01 +0200 Subject: [PATCH] Add efficiency and deadline scoring --- scoreboard/data/threads-config.yml | 9 +++++++ scoreboard/main.py | 38 ++++++++++++++++++++++++++++++ scoreboard/templates/index.html.j2 | 4 ++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/scoreboard/data/threads-config.yml b/scoreboard/data/threads-config.yml index 1c950787b..ed8b5683c 100644 --- a/scoreboard/data/threads-config.yml +++ b/scoreboard/data/threads-config.yml @@ -38,3 +38,12 @@ scoreboard: visible: true plagiarism: coefficient: 0.5 + efficiency: + num_proc: 4 + deadlines: + mpi: "2025-12-31" + omp: "2025-12-31" + seq: "2025-12-31" + stl: "2025-12-31" + tbb: "2025-12-31" + all: "2025-12-31" diff --git a/scoreboard/main.py b/scoreboard/main.py index 67a95913c..fd70c31a5 100644 --- a/scoreboard/main.py +++ b/scoreboard/main.py @@ -1,6 +1,8 @@ from pathlib import Path from collections import defaultdict +from datetime import datetime import argparse +import subprocess import yaml import csv from jinja2 import Environment, FileSystemLoader @@ -29,6 +31,8 @@ with open(config_path, 'r') as file: cfg = yaml.safe_load(file) assert cfg, "Configuration is empty" +eff_num_proc = int(cfg["scoreboard"].get("efficiency", {}).get("num_proc", 1)) +deadlines_cfg = cfg["scoreboard"].get("deadlines", {}) plagiarism_config_path = Path(__file__).parent / "data" / "plagiarism.yml" with open(plagiarism_config_path, 'r') as file: plagiarism_cfg = yaml.safe_load(file) @@ -83,11 +87,45 @@ perf_val = perf_stats.get(dir, {}).get(task_type, "?") + # Calculate efficiency if performance data is available + efficiency = "?" + try: + perf_float = float(perf_val) + if perf_float > 0: + speedup = 1.0 / perf_float + efficiency = f"{speedup / eff_num_proc * 100:.2f}" + except (ValueError, TypeError): + pass + + # Calculate deadline penalty points + deadline_points = 0 + deadline_str = deadlines_cfg.get(task_type) + if status == "done" and deadline_str: + try: + deadline_dt = datetime.fromisoformat(deadline_str) + git_cmd = [ + "git", + "log", + "-1", + "--format=%ct", + str(tasks_dir / (dir + ("_disabled" if status == "disabled" else "")) / task_type), + ] + result = subprocess.run(git_cmd, capture_output=True, text=True) + if result.stdout.strip().isdigit(): + commit_dt = datetime.fromtimestamp(int(result.stdout.strip())) + days_late = (commit_dt - deadline_dt).days + if days_late > 0: + deadline_points = -days_late + except Exception: + pass + row_types.append( { "solution_points": sol_points, "solution_style": solution_style, "perf": perf_val, + "efficiency": efficiency, + "deadline_points": deadline_points, "plagiarised": is_cheated, "plagiarism_points": plagiarism_points, } diff --git a/scoreboard/templates/index.html.j2 b/scoreboard/templates/index.html.j2 index 713215a41..700d5463e 100644 --- a/scoreboard/templates/index.html.j2 +++ b/scoreboard/templates/index.html.j2 @@ -37,8 +37,8 @@ {% for cell in row.types %} {{ cell.solution_points }} {{ cell.perf }} - 0 - 0 + {{ cell.efficiency }} + {{ cell.deadline_points }} {{ cell.plagiarism_points }} {% endfor %} {{ row.total }}