-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.
Description
The test
crate is not stable, and I’m not aware of plans to stabilize it soon. It’s probably better to spend some time experimenting on crates.io using harness = false
in Cargo.toml
(see rust-lang/cargo#2305).
I’ve extracted the test crate to eventually publish it separately and am removing usage of unstable features one by one. One of them is asm
, used in:
/// A function that is opaque to the optimizer, to allow benchmarks to
/// pretend to use outputs to assist in avoiding dead-code
/// elimination.
///
/// This function is a no-op, and does not even read from `dummy`.
#[cfg(not(all(target_os = "nacl", target_arch = "le32")))]
pub fn black_box<T>(dummy: T) -> T {
// we need to "use" the argument in some way LLVM can't
// introspect.
unsafe { asm!("" : : "r"(&dummy)) }
dummy
}
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
#[inline(never)]
pub fn black_box<T>(dummy: T) -> T {
dummy
}
It’s an important part of benchmarking. Since asm!
is not stable and also unlikely to be stable soon, I’d like to have black_box
stabilized in std
, as a building block for external test and benchmarking harnesses.
I’m not sure what module it would go into. Maybe std::time
?
ruuda, jonhoo, ZaneHannanAU, elichai and zakcutner
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the RFC.Relevant to the library API team, which will review and decide on the RFC.