mirror of
https://github.com/kristoferssolo/Advent-of-Code.git
synced 2025-10-21 18:00:35 +00:00
refactor(day-01): use new template
This commit is contained in:
parent
9020a27a4a
commit
cf14bce68e
1
2024/.gitignore
vendored
1
2024/.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
/target
|
||||
day-*.bench.txt
|
||||
.env
|
||||
input*.txt
|
||||
|
||||
19
2024/benchmarks.txt
Normal file
19
2024/benchmarks.txt
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
running 2 tests
|
||||
ii
|
||||
test result: ok. 0 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
||||
|
||||
day_01_bench fastest │ slowest │ median │ mean │ samples │ iters
|
||||
├─ part1 89.39 µs │ 119 µs │ 89.79 µs │ 92.23 µs │ 100 │ 100
|
||||
╰─ part2 237.9 µs │ 310.8 µs │ 241.7 µs │ 244.3 µs │ 100 │ 100
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use miette::Result;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub fn process(input: &str) -> Result<usize> {
|
||||
todo!("day xx - part 1");
|
||||
Ok(0)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use miette::Result;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub fn process(input: &str) -> Result<usize> {
|
||||
todo!("day xx - part 2");
|
||||
Ok(0)
|
||||
|
||||
6
2024/day-01.bench.txt
Normal file
6
2024/day-01.bench.txt
Normal file
@ -0,0 +1,6 @@
|
||||
day_01_bench fastest │ slowest │ median │ mean │ samples │ iters
|
||||
╰─ part1 94.58 µs │ 120 µs │ 96.14 µs │ 97.09 µs │ 100 │ 100
|
||||
|
||||
day_01_bench fastest │ slowest │ median │ mean │ samples │ iters
|
||||
╰─ part2 259 µs │ 351.9 µs │ 262.6 µs │ 265.9 µs │ 100 │ 100
|
||||
|
||||
@ -6,4 +6,18 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
color-eyre.workspace = true
|
||||
itertools.workspace = true
|
||||
nom.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
miette.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
divan.workspace = true
|
||||
rstest.workspace = true
|
||||
test-log.workspace = true
|
||||
|
||||
[[bench]]
|
||||
name = "day-01-bench"
|
||||
path = "benches/benchmarks.rs"
|
||||
harness = false
|
||||
|
||||
21
2024/day-01/benches/benchmarks.rs
Normal file
21
2024/day-01/benches/benchmarks.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use day_01::*;
|
||||
|
||||
fn main() {
|
||||
divan::main();
|
||||
}
|
||||
|
||||
#[divan::bench]
|
||||
fn part1() {
|
||||
part1::process(divan::black_box(include_str!(
|
||||
"../input1.txt",
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[divan::bench]
|
||||
fn part2() {
|
||||
part2::process(divan::black_box(include_str!(
|
||||
"../input2.txt",
|
||||
)))
|
||||
.unwrap();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,12 @@
|
||||
use color_eyre::Result;
|
||||
use day_01::part1::process;
|
||||
use miette::{Context, Result};
|
||||
|
||||
#[tracing::instrument]
|
||||
fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let file = include_str!("../../input1.txt");
|
||||
let result = process(file)?;
|
||||
let result = process(file).context("process part 1")?;
|
||||
println!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
use color_eyre::Result;
|
||||
use day_01::part2::process;
|
||||
use miette::{Context, Result};
|
||||
|
||||
#[tracing::instrument]
|
||||
fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
let file = include_str!("../../input2.txt");
|
||||
let result = process(file)?;
|
||||
let result = process(file).context("process part 2")?;
|
||||
println!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use color_eyre::Result;
|
||||
use miette::Result;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub fn process(input: &str) -> Result<usize> {
|
||||
let (mut firsts, mut lasts): (Vec<_>, Vec<_>) = input
|
||||
.lines()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use color_eyre::Result;
|
||||
use miette::Result;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub fn process(input: &str) -> Result<usize> {
|
||||
let sum = {
|
||||
let (firsts, lasts): (Vec<_>, Vec<_>) = input
|
||||
|
||||
Loading…
Reference in New Issue
Block a user