AOC Sync
A Python script that polls multiple git repositories containing Advent of Code implementations written in Rust using cargo-aoc format. It automatically updates repositories when changes are detected, runs benchmarks, and generates a beautiful HTML comparison page showing performance metrics across users, years, and days.
Features
- Automatic Git Polling: Monitors multiple repositories for changes
- Flexible Repository Structure: Supports both single-repo (all years) and multi-repo (one per year) configurations
- Automatic Runtime Measurement: Runs
cargo aocfor all implemented days and parses runtime information - Performance Parsing: Extracts timing data from cargo-aoc output
- Data Storage: SQLite database for historical performance data
- HTML Reports: Beautiful, responsive HTML comparison pages
- Gap Handling: Gracefully handles missing years, days, and parts
- Configurable Comparisons: Filter by specific years and days
Requirements
- Python 3.7+
- Git
- Rust and Cargo
cargo-aocinstalled (install withcargo install cargo-aoc)
Installation
- Clone this repository:
git clone <repository-url>
cd aocsync
- Install Python dependencies:
pip install -r requirements.txt
- Ensure
cargo-aocis installed:
cargo install cargo-aoc
Note: The script runs cargo aoc (not cargo aoc bench) and parses runtime information from the output.
Configuration
Edit config.yaml to configure repositories to monitor:
# Poll interval in seconds
poll_interval: 300
# Output directory for generated HTML
output_dir: "output"
# Data storage directory
data_dir: "data"
# Repositories to monitor
repositories:
# Single repository with all years
- name: "user1"
url: "https://github.com/user1/advent-of-code"
type: "single"
local_path: "repos/user1"
# Multiple repositories, one per year
- name: "user2"
type: "multi-year"
years:
- year: 2023
url: "https://github.com/user2/aoc-2023"
local_path: "repos/user2-2023"
- year: 2024
url: "https://github.com/user2/aoc-2024"
local_path: "repos/user2-2024"
# Optional: Filter specific years to compare
compare_years: [2023, 2024]
# Optional: Filter specific days to compare
# compare_days: [1, 2, 3, 4, 5]
Usage
Run Once
To sync repositories and generate a report once:
python aocsync.py --once
Force Rerun All Days
To force rerun all days even if repositories haven't changed:
python aocsync.py --once --force
or
python aocsync.py --once --rerun-all
This is useful for refreshing all data or testing changes to the script.
Continuous Polling
To continuously poll repositories (default):
python aocsync.py
Or with a custom config file:
python aocsync.py --config myconfig.yaml
Output
- Database: Performance data is stored in
data/results.db(SQLite) - HTML Report: Generated at
output/index.html(configurable viaoutput_dir)
The HTML report includes:
- Performance comparison tables for each year/day/part
- Visual highlighting of fastest and slowest implementations
- Relative speed comparisons (X times faster/slower)
- Responsive design for viewing on any device
How It Works
- Git Polling: Checks each configured repository for changes by comparing local and remote commits
- Repository Update: Clones new repositories or updates existing ones when changes are detected
- Day Detection: Automatically finds implemented days by scanning for
day*.rsfiles and Cargo.toml entries - Runtime Measurement: Runs
cargo aoc --day Xfor each implemented day - Parsing: Extracts timing data from cargo-aoc output (handles nanoseconds, microseconds, milliseconds, seconds)
- Storage: Stores results in SQLite database with timestamps
- Report Generation: Generates HTML comparison page showing latest results
Repository Structure Detection
The script automatically detects:
- Year: From repository path, name, or Cargo.toml
- Days: From
src/bin/day*.rs,src/day*.rs, or Cargo.toml entries - Parts: From cargo-aoc benchmark output (Part 1, Part 2)
Troubleshooting
Cargo-aoc not found
Ensure cargo-aoc is installed and in your PATH:
cargo install cargo-aoc
Git authentication issues
For private repositories, ensure your git credentials are configured or use SSH URLs.
Benchmark timeouts
If benchmarks take too long, the script has a 5-minute timeout per day. Adjust in the code if needed.
Missing performance data
If some users/days/parts don't show up:
- Check that
cargo aoc --day Xruns successfully in the repository - Verify the repository structure matches cargo-aoc conventions
- Ensure
cargo aocoutputs timing information (check if it's configured to show runtime) - Check logs for parsing errors
License
[Your License Here]