Added benchmarking for each day
This commit is contained in:
parent
4267b68253
commit
308c456fa4
38
src/main.rs
38
src/main.rs
@ -1,26 +1,40 @@
|
|||||||
mod utils;
|
|
||||||
mod solutions;
|
mod solutions;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
use std::error::Error;
|
use std::{error::Error, time::SystemTime};
|
||||||
|
|
||||||
use solutions::*;
|
use solutions::*;
|
||||||
|
|
||||||
use crate::utils::get_input;
|
use crate::utils::get_input;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>>{
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let days: Vec<Box<dyn Solution>> = vec![Box::new(day01::Day01 {}), Box::new(day02::Day02 {})];
|
||||||
let days: Vec<Box<dyn Solution>> = vec![
|
|
||||||
Box::new(day01::Day01{}),
|
|
||||||
Box::new(day02::Day02{})
|
|
||||||
];
|
|
||||||
|
|
||||||
// Run through and generate solutions
|
// Run through and generate solutions
|
||||||
for day in days.iter().rev() {
|
for day in days.iter().rev() {
|
||||||
println!("Day{} Part1 Test: {}", day.get_day(), day.part1(get_input(day.get_day(), utils::InputType::Test1)?.as_mut())?);
|
println!("========== Day {} ==========", day.get_day());
|
||||||
println!("Day{} Part1 Result: {}", day.get_day(), day.part1(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?);
|
let start_time = SystemTime::now();
|
||||||
|
println!(
|
||||||
|
"Part1 Test: {}",
|
||||||
|
day.part1(get_input(day.get_day(), utils::InputType::Test1)?.as_mut())?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"Part1 Result: {}",
|
||||||
|
day.part1(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?
|
||||||
|
);
|
||||||
|
|
||||||
println!("Day{} Part2 Test: {}", day.get_day(), day.part2(get_input(day.get_day(), utils::InputType::Test2)?.as_mut())?);
|
println!(
|
||||||
println!("Day{} Part2 Result: {}", day.get_day(), day.part2(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?);
|
"Part2 Test: {}",
|
||||||
|
day.part2(get_input(day.get_day(), utils::InputType::Test2)?.as_mut())?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"Part2 Result: {}",
|
||||||
|
day.part2(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
"========= {}ms =========",
|
||||||
|
SystemTime::now().duration_since(start_time)?.as_millis()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user