diff --git a/aocsync.py b/aocsync.py index dc10cee..ef4f948 100755 --- a/aocsync.py +++ b/aocsync.py @@ -832,6 +832,97 @@ class HTMLGenerator: logger.info(f"Generated HTML report: {output_file}") + @staticmethod + def _generate_svg_graph(data_points: List[dict]) -> str: + """Generate an SVG line graph showing performance over time""" + if len(data_points) < 2: + return "" + + # Graph dimensions + width = 600 + height = 200 + padding = 40 + graph_width = width - 2 * padding + graph_height = height - 2 * padding + + # Extract time values + times = [dp['time_ns'] for dp in data_points] + min_time = min(times) + max_time = max(times) + # Add 10% padding to range for better visualization, or minimum 1% of max value + time_range = max_time - min_time if max_time > min_time else max(max_time * 0.01, 1) + if time_range > 0: + padding_amount = time_range * 0.1 + min_time = max(0, min_time - padding_amount) + max_time = max_time + padding_amount + time_range = max_time - min_time + + # Format time for display + def format_time(ns): + ms = ns / 1_000_000 + us = ns / 1_000 + if ms >= 1: + return f"{ms:.2f}ms" + elif us >= 1: + return f"{us:.2f}μs" + else: + return f"{ns}ns" + + # Generate SVG + svg_parts = [] + svg_parts.append(f'') + return ''.join(svg_parts) + def _generate_html(self, data: dict, years: List[int], users: List[str], db: Database) -> str: """Generate HTML content""" # Sort years descending (most recent first) @@ -1119,6 +1210,13 @@ class HTMLGenerator: border-bottom: none; }} + .history-graph {{ + margin: 15px 0; + padding: 10px; + background: white; + border-radius: 4px; + }} + .summary {{ margin-top: 30px; padding: 15px; @@ -1347,7 +1445,8 @@ class HTMLGenerator: history_link = "" if len(historical) > 1: history_items = [] - for hist in historical[:10]: # Show last 10 runs + hist_data_points = [] + for hist in historical[:20]: # Show last 20 runs for graph hist_total = hist['time_ns'] + hist.get('generator_time_ns', 0) hist_ms = hist_total / 1_000_000 hist_us = hist_total / 1_000 @@ -1366,6 +1465,16 @@ class HTMLGenerator: else: hist_git_link = hist_git history_items.append(f'