Skip to content

Commit 1763484

Browse files
committed
chore: use std::hint::black_box
It has been stable for quite a while now.
1 parent 5caa771 commit 1763484

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

crates/codspeed/src/codspeed.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
use std::{ffi::CString, mem::forget, ptr};
2-
1+
use crate::measurement;
32
use colored::Colorize;
3+
use std::ffi::CString;
44

5-
use crate::measurement;
5+
pub use std::hint::black_box;
66

77
pub const WARMUP_RUNS: u32 = 5;
88

9-
//TODO: use std::hint::black_box when it's stable
10-
pub fn black_box<T>(dummy: T) -> T {
11-
unsafe {
12-
let ret = ptr::read_volatile(&dummy);
13-
forget(dummy);
14-
ret
15-
}
16-
}
17-
189
pub fn display_native_harness() {
1910
println!("Harness: codspeed v{}", env!("CARGO_PKG_VERSION"),);
2011
}

0 commit comments

Comments
 (0)