Skip to content

Commit 8251f1a

Browse files
committed
Misc
1 parent 7485f45 commit 8251f1a

5 files changed

Lines changed: 13 additions & 199 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ target/
2121
!*/data/inputs/.keep
2222
*/data/puzzles/*
2323
!*/data/puzzles/.keep
24+
*/data/timings.json

advent_of_code/src/template/commands/time.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::HashSet;
22

33
use crate::template::run_multi::run_multi;
44
use crate::template::timings::Timings;
5-
use crate::template::{all_days, readme_benchmarks, Day};
5+
use crate::template::{all_days, Day};
66

77
pub fn handle(day: Option<Day>, run_all: bool, store: bool) {
88
let stored_timings = Timings::read_from_file();
@@ -26,15 +26,5 @@ pub fn handle(day: Option<Day>, run_all: bool, store: bool) {
2626
if store {
2727
let merged_timings = stored_timings.merge(&timings);
2828
merged_timings.store_file().unwrap();
29-
30-
println!();
31-
match readme_benchmarks::update(merged_timings) {
32-
Ok(()) => {
33-
println!("Stored updated benchmarks.");
34-
}
35-
Err(_) => {
36-
eprintln!("Failed to store updated benchmarks.");
37-
}
38-
}
3929
}
4030
}

advent_of_code/src/template/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod runner;
77
pub use day::*;
88

99
mod day;
10-
mod readme_benchmarks;
1110
mod run_multi;
1211
mod timings;
1312

advent_of_code/src/template/readme_benchmarks.rs

Lines changed: 0 additions & 183 deletions
This file was deleted.

advent_of_code/src/template/timings.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
use std::{collections::HashMap, fs, io::Error, str::FromStr};
1+
use std::{
2+
collections::HashMap,
3+
fs,
4+
io::{Error, ErrorKind},
5+
str::FromStr,
6+
};
27
use tinyjson::JsonValue;
38

49
use crate::template::Day;
@@ -31,9 +36,11 @@ impl Timings {
3136

3237
/// Rehydrate timings from a JSON file. If not present, returns empty timings.
3338
pub fn read_from_file() -> Self {
34-
let s = fs::read_to_string(TIMINGS_FILE_PATH)
35-
.map_err(|x| x.to_string())
36-
.and_then(Timings::try_from);
39+
let s = match fs::read_to_string(TIMINGS_FILE_PATH) {
40+
Ok(s) => Timings::try_from(s),
41+
Err(e) if e.kind() == ErrorKind::NotFound => Ok(Timings::default()),
42+
Err(e) => Err(e.to_string()),
43+
};
3744

3845
match s {
3946
Ok(timings) => timings,

0 commit comments

Comments
 (0)