Last active
January 13, 2021 09:43
-
-
Save justanotherdot/0b0051f96bdeb44c25ad58998910f6a1 to your computer and use it in GitHub Desktop.
Drop in benchmark snippet for Rust projects that want to use cargo-bench on nightly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NB. this must be placed at the top of the module. | |
#![feature(test)] | |
#[cfg(test)] | |
mod tests { | |
extern crate test; | |
use super::*; | |
use test::{black_box, Bencher}; | |
#[bench] | |
fn bench_x(b: &mut Bencher) { | |
b.iter(|| { | |
for i in 1..2 { | |
black_box(()); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment