Skip to content

feat: use black_box for benchmark evaluation #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/template/runner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Encapsulates code that interacts with solution functions.
use crate::template::{aoc_cli, Day, ANSI_ITALIC, ANSI_RESET};
use std::fmt::Display;
use std::hint::black_box;
use std::io::{stdout, Write};
use std::process::Output;
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -64,7 +65,7 @@ fn bench<I: Clone, T>(func: impl Fn(I) -> T, input: I, base_time: &Duration) ->
// need a clone here to make the borrow checker happy.
let cloned = input.clone();
let timer = Instant::now();
func(cloned);
black_box(func(black_box(cloned)));
timers.push(timer.elapsed());
}

Expand Down