-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70fcac7
commit c124d39
Showing
14 changed files
with
99 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: CodSpeed | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
# `workflow_dispatch` allows CodSpeed to trigger backtest | ||
# performance analysis in order to generate initial data. | ||
workflow_dispatch: | ||
|
||
jobs: | ||
benchmarks: | ||
name: Run benchmarks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup rust toolchain, cache and cargo-codspeed binary | ||
uses: moonrepo/setup-rust@v1 | ||
with: | ||
cache-target: release | ||
bins: cargo-codspeed, aoc-cli | ||
|
||
- name: Download available input files | ||
env: | ||
ADVENT_OF_CODE_SESSION: ${{ secrets.AOC_SESSION }} | ||
run: | | ||
mkdir -p inputs | ||
for i in {1..25}; do | ||
aoc download -I -i inputs/day$i.txt --year 2024 -d $i || true | ||
done | ||
- name: Build the benchmark target(s) | ||
run: cargo codspeed build | ||
|
||
- name: Run the benchmarks | ||
uses: CodSpeedHQ/action@v3 | ||
with: | ||
run: cargo codspeed run | ||
token: ${{ secrets.CODSPEED_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use paste::paste; | ||
|
||
/// Get input for a single day | ||
macro_rules! get_day_input { | ||
($day_num:literal) => { | ||
include_str!(concat!("../inputs/day", $day_num, ".txt")) | ||
}; | ||
} | ||
|
||
/// Define benchmarks for a single day with part1 and part2 | ||
macro_rules! benches_day { | ||
($day_num:literal) => { | ||
paste! { | ||
use advent_of_code_2024::[<day $day_num>]; | ||
|
||
pub fn [<bench_day $day_num>](c: &mut Criterion) { | ||
let mut group = c.benchmark_group(concat!("day", $day_num)); | ||
let input = get_day_input!($day_num); | ||
group.bench_function(format!("day{}_part1", $day_num), |b| b.iter(|| [<day $day_num>]::part1(input))); | ||
group.bench_function(format!("day{}_part2", $day_num), |b| b.iter(|| [<day $day_num>]::part2(input))); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/// Create benchmarks for included days | ||
macro_rules! benches { | ||
($($day_num:literal),*) => { | ||
paste! { | ||
$( | ||
benches_day!($day_num); | ||
)* | ||
|
||
criterion_group!(benches, $([<bench_day $day_num>]),*); | ||
criterion_main!(benches); | ||
} | ||
}; | ||
} | ||
|
||
benches!(1, 2, 3, 4, 5, 7, 8, 9, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ pub mod day2; | |
pub mod day3; | ||
pub mod day4; | ||
pub mod day5; | ||
pub mod day7; | ||
pub mod day8; | ||
pub mod day9; | ||
|
||
|