Benchmark improvement
This commit is contained in:
parent
6882c31777
commit
2c0f98bda8
1 changed files with 2 additions and 4 deletions
|
@ -184,11 +184,8 @@ async fn main() {
|
||||||
};
|
};
|
||||||
let mut timings = Vec::<Duration>::new();
|
let mut timings = Vec::<Duration>::new();
|
||||||
let large = input_type == InputType::Large;
|
let large = input_type == InputType::Large;
|
||||||
for _ in 1..warmup {
|
|
||||||
day.solve(part, large);
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in 1..=n {
|
for i in 1..=(n+warmup) {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
day.solve(part, large);
|
day.solve(part, large);
|
||||||
let end = Instant::now();
|
let end = Instant::now();
|
||||||
|
@ -197,6 +194,7 @@ async fn main() {
|
||||||
print!("\r{:.2}%", (i as f32 / n as f32) * 100.0);
|
print!("\r{:.2}%", (i as f32 / n as f32) * 100.0);
|
||||||
let _ = std::io::stdout().flush();
|
let _ = std::io::stdout().flush();
|
||||||
}
|
}
|
||||||
|
timings.drain(..=(warmup as usize));
|
||||||
let avg = (timings.iter().sum::<Duration>() / n).as_nanos();
|
let avg = (timings.iter().sum::<Duration>() / n).as_nanos();
|
||||||
let deviation = (avg - timings.iter().min().unwrap().as_nanos())
|
let deviation = (avg - timings.iter().min().unwrap().as_nanos())
|
||||||
.max(timings.iter().max().unwrap().as_nanos() - avg);
|
.max(timings.iter().max().unwrap().as_nanos() - avg);
|
||||||
|
|
Loading…
Reference in a new issue