File tree Expand file tree Collapse file tree 4 files changed +5
-28
lines changed Expand file tree Collapse file tree 4 files changed +5
-28
lines changed Original file line number Diff line number Diff line change @@ -105,24 +105,6 @@ impl BenchmarkGroup {
105
105
}
106
106
}
107
107
108
- /// Adds a single benchmark to the benchmark group.
109
- /// ```ignore
110
- /// use benchlib::define_benchmark;
111
- ///
112
- /// define_benchmark!(group, my_bench, {
113
- /// || do_something()
114
- /// });
115
- /// ```
116
- #[ macro_export]
117
- macro_rules! define_benchmark {
118
- ( $group: expr, $name: ident, $fun: expr) => {
119
- let func = move || $fun;
120
- $group. register_benchmark( stringify!( $name) , func) ;
121
- } ;
122
- }
123
-
124
- pub use define_benchmark;
125
-
126
108
/// Tests if the name of the benchmark passes through the include and exclude filters.
127
109
/// Both filters can contain multiple comma-separated prefixes.
128
110
pub fn passes_filter ( name : & str , exclude : Option < & str > , include : Option < & str > ) -> bool {
Original file line number Diff line number Diff line change 1
- use std:: io:: { BufRead , BufReader , Write } ;
2
-
3
- use snap:: { read:: FrameDecoder , write:: FrameEncoder } ;
4
-
5
1
use benchlib:: benchmark:: { black_box, run_benchmark_group} ;
6
- use benchlib:: define_benchmark;
2
+ use snap:: { read:: FrameDecoder , write:: FrameEncoder } ;
3
+ use std:: io:: { BufRead , BufReader , Write } ;
7
4
8
5
const BYTES : usize = 64 * 1024 * 1024 ;
9
6
@@ -12,7 +9,7 @@ fn main() {
12
9
// The pattern we want is a BufReader which wraps a Read impl where one Read::read call will
13
10
// never fill the whole BufReader buffer.
14
11
run_benchmark_group ( |group| {
15
- define_benchmark ! ( group, bufreader_snappy, {
12
+ group. register_benchmark ( " bufreader_snappy" , || {
16
13
let data = vec ! [ 0u8 ; BYTES ] ;
17
14
move || {
18
15
let mut compressed = Vec :: new ( ) ;
Original file line number Diff line number Diff line change 1
1
use benchlib;
2
2
use benchlib:: benchmark:: run_benchmark_group;
3
- use benchlib:: define_benchmark;
4
3
5
4
fn main ( ) {
6
5
run_benchmark_group ( |group| {
7
6
// Measures how long does it take to insert 10 thousand numbers into a `hashbrown` hashmap.
8
- define_benchmark ! ( group, hashmap_insert_10k, {
7
+ group. register_benchmark ( " hashmap_insert_10k" , || {
9
8
let mut map = hashbrown:: HashMap :: with_capacity_and_hasher (
10
9
10000 ,
11
10
fxhash:: FxBuildHasher :: default ( ) ,
Original file line number Diff line number Diff line change 2
2
//! Code taken from https://github.com/prestontw/rust-nbody
3
3
4
4
use benchlib:: benchmark:: run_benchmark_group;
5
- use benchlib:: define_benchmark;
6
5
7
6
mod nbody;
8
7
9
8
fn main ( ) {
10
9
run_benchmark_group ( |group| {
11
- define_benchmark ! ( group, nbody_10k, {
10
+ group. register_benchmark ( " nbody_10k" , || {
12
11
let mut nbody_10k = nbody:: init ( 10000 ) ;
13
12
|| {
14
13
for _ in 0 ..10 {
You can’t perform that action at this time.
0 commit comments