Better timing logs in previous days

This commit is contained in:
Tyler Hallada 2020-12-10 01:23:58 -05:00
parent 646539557f
commit 180e6743a6
9 changed files with 58 additions and 28 deletions

View File

@ -1,9 +1,10 @@
use anyhow::{anyhow, Result};
use std::collections::HashSet; use std::collections::HashSet;
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
use std::io::BufReader; use std::io::BufReader;
use std::time::Instant;
use anyhow::{anyhow, Result};
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -44,8 +45,13 @@ fn solve_part2(input_path: &str) -> Result<i32> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,10 +1,11 @@
use anyhow::{Context, Error, Result};
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
use std::io::BufReader; use std::io::BufReader;
use std::ops::RangeInclusive; use std::ops::RangeInclusive;
use std::str::FromStr; use std::str::FromStr;
use std::time::Instant;
use anyhow::{Context, Error, Result};
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -106,8 +107,13 @@ fn solve_part2(input_path: &str) -> Result<usize> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,9 +1,10 @@
use anyhow::Result;
use std::fmt; use std::fmt;
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
use std::io::BufReader; use std::io::BufReader;
use std::time::Instant;
use anyhow::Result;
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -117,8 +118,13 @@ fn solve_part2(input_path: &str) -> Result<usize> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,9 +1,10 @@
use anyhow::{anyhow, Context, Error, Result};
use std::fmt; use std::fmt;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use std::str::FromStr; use std::str::FromStr;
use std::time::Instant;
use anyhow::{anyhow, Context, Error, Result};
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -213,8 +214,13 @@ fn solve_part2(input_path: &str) -> Result<usize> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,9 +1,10 @@
use anyhow::{anyhow, Error, Result};
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
use std::io::BufReader; use std::io::BufReader;
use std::str::FromStr; use std::str::FromStr;
use std::time::Instant;
use anyhow::{anyhow, Error, Result};
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -73,8 +74,13 @@ fn solve_part2(input_path: &str) -> Result<u32> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -1,7 +1,8 @@
use anyhow::Result;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fs::read_to_string; use std::fs::read_to_string;
use std::time::Instant;
use anyhow::Result;
const INPUT: &str = "input/input.txt"; const INPUT: &str = "input/input.txt";
@ -44,8 +45,13 @@ fn solve_part2(input_path: &str) -> Result<usize> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -5,6 +5,7 @@ extern crate maplit;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use std::time::Instant;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use regex::Regex; use regex::Regex;
@ -125,8 +126,13 @@ fn solve_part2(input_path: &str) -> Result<u32> {
} }
fn main() { fn main() {
let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
now = Instant::now();
println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!("(elapsed: {:?})", now.elapsed());
} }
#[cfg(test)] #[cfg(test)]

View File

@ -112,17 +112,11 @@ fn solve_part2(input_path: &str) -> Result<i32> {
fn main() { fn main() {
let mut now = Instant::now(); let mut now = Instant::now();
println!("Part 1: {}", solve_part1(INPUT).unwrap()); println!("Part 1: {}", solve_part1(INPUT).unwrap());
println!( println!("(elapsed: {:?})", now.elapsed());
"(elapsed: {} ms)",
now.elapsed().as_micros() as f32 / 1000_f32
);
now = Instant::now(); now = Instant::now();
println!(""); println!("");
println!("Part 2: {}", solve_part2(INPUT).unwrap()); println!("Part 2: {}", solve_part2(INPUT).unwrap());
println!( println!("(elapsed: {:?})", now.elapsed());
"(elapsed: {} ms)",
now.elapsed().as_micros() as f32 / 1000_f32
);
} }
#[cfg(test)] #[cfg(test)]

View File

@ -67,17 +67,11 @@ fn main() {
let mut now = Instant::now(); let mut now = Instant::now();
let part1 = solve_part1(INPUT, 25).unwrap(); let part1 = solve_part1(INPUT, 25).unwrap();
println!("Part 1: {}", part1); println!("Part 1: {}", part1);
println!( println!("(elapsed: {:?})", now.elapsed());
"(elapsed: {} ms)",
now.elapsed().as_micros() as f32 / 1000_f32
);
now = Instant::now(); now = Instant::now();
println!(""); println!("");
println!("Part 2: {}", solve_part2(INPUT, part1).unwrap()); println!("Part 2: {}", solve_part2(INPUT, part1).unwrap());
println!( println!("(elapsed: {:?})", now.elapsed());
"(elapsed: {} ms)",
now.elapsed().as_micros() as f32 / 1000_f32
);
} }
#[cfg(test)] #[cfg(test)]