add runtime measurement

This commit is contained in:
Fabian Schmidt 2024-12-10 11:45:53 +01:00
parent 64cb7fb370
commit dd6e9dbe90
54 changed files with 417 additions and 47 deletions

4
Cargo.lock generated
View File

@ -89,6 +89,7 @@ name = "y2016"
version = "0.1.0"
dependencies = [
"md5",
"utils",
]
[[package]]
@ -114,6 +115,9 @@ version = "0.1.0"
[[package]]
name = "y2022"
version = "0.1.0"
dependencies = [
"utils",
]
[[package]]
name = "y2023"

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y{{YEAR}}::days::d{{DAY}};
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,20 +1,27 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d1;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/1_input.txt")).unwrap();
println!("{}", d1::process_part1(&content));
println!("Answer: {}", d1::process_part1(&content));
}
fn part2() {
let root = env!("CARGO_MANIFEST_DIR");
let content = fs::read_to_string(format!("{root}/resources/1_input.txt")).unwrap();
println!("{}", d1::process_part2(&content));
println!("Answer: {}", d1::process_part2(&content));
}

View File

@ -1,8 +1,17 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2015::days::d10;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,8 +1,17 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2015::days::d11;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d12;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d13;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d14;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d15;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d16;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d17;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d18;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d19;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d2;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,8 +1,17 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2015::days::d20;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d21;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d22;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d23;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d24;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,7 +1,13 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2015::days::d25;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d3;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2015::days::d4;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d5;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d6;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d7;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d8;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2015::days::d9;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -5,3 +5,4 @@ edition = "2021"
[dependencies]
md5 = { workspace = true }
utils = { workspace = true }

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2016::days::d1;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2016::days::d2;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2016::days::d3;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2016::days::d4;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,8 +1,17 @@
use std::time::Instant;
use utils::time::get_elapsed_string;
use y2016::days::d5;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2016::days::d6;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2021"
[dependencies]
utils = { workspace = true }

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d1;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d2::{process_part1, process_part2};
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d3;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d4;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d5;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d6;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d7;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d8;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2022::days::d9;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d1;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d10;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d2;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d3;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d4;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d5;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d6;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d7;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d8;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {

View File

@ -1,10 +1,17 @@
use std::fs;
use std::{fs, time::Instant};
use utils::time::get_elapsed_string;
use y2024::days::d9;
fn main() {
let now = Instant::now();
println!("Part 1:");
part1();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
let now = Instant::now();
println!("Part 2:");
part2();
println!("Ran in {}", get_elapsed_string(now.elapsed()));
}
fn part1() {