Skip to content

Commit

Permalink
using humantime duration formatting for timings
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Nov 11, 2023
1 parent 805fe13 commit 477eb65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion aoc-solution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"

[dependencies]
anyhow = { workspace = true }
aoc-derive = { path = "../aoc-solution-derive" }
aoc-derive = { path = "../aoc-solution-derive" }
humantime = "2.1.0"
7 changes: 4 additions & 3 deletions aoc-solution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use humantime::format_duration;
use std::any::type_name;
use std::fmt::{Display, Formatter};
use std::path::Path;
Expand Down Expand Up @@ -64,9 +65,9 @@ pub struct DayResult<T: AocSolution + ?Sized> {
impl<T: AocSolution + ?Sized> Display for DayResult<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
writeln!(f, "# TIMING #")?;
writeln!(f, "PARSING:\t{:?}", self.parsing)?;
writeln!(f, "PART 1:\t\t{:?}", self.part1.taken)?;
writeln!(f, "PART 2:\t\t{:?}", self.part2.taken)?;
writeln!(f, "PARSING:\t{}", format_duration(self.parsing))?;
writeln!(f, "PART 1:\t\t{}", format_duration(self.part1.taken))?;
writeln!(f, "PART 2:\t\t{}", format_duration(self.part2.taken))?;
writeln!(f)?;
writeln!(f, "# RESULTS #")?;
let display_p1 = match &self.part1.value {
Expand Down

0 comments on commit 477eb65

Please sign in to comment.