boilerplate: add timing

This commit is contained in:
Keenan Tims 2023-12-12 02:24:24 -08:00
parent a431c4b75f
commit c797e874d5
Signed by: ktims
GPG Key ID: 11230674D69038D4

View File

@ -1,5 +1,6 @@
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader, Lines}; use std::io::{BufRead, BufReader, Lines};
use std::time::{Duration, Instant};
// BOILERPLATE // BOILERPLATE
type InputIter = Lines<BufReader<File>>; type InputIter = Lines<BufReader<File>>;
@ -11,8 +12,15 @@ fn get_input() -> InputIter {
} }
fn main() { fn main() {
println!("Problem 1 solution: {}", problem1(get_input())); let start = Instant::now();
println!("Problem 2 solution: {}", problem2(get_input())); let ans1 = problem1(get_input());
let duration = start.elapsed();
println!("Problem 1 solution: {} [{}s]", ans1, duration.as_secs_f64());
let start = Instant::now();
let ans2 = problem2(get_input());
let duration = start.elapsed();
println!("Problem 2 solution: {} [{}s]", ans2, duration.as_secs_f64());
} }
// PROBLEM 1 solution // PROBLEM 1 solution