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 {
105105 }
106106}
107107
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-
126108/// Tests if the name of the benchmark passes through the include and exclude filters.
127109/// Both filters can contain multiple comma-separated prefixes.
128110pub 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-
51use 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 } ;
74
85const BYTES : usize = 64 * 1024 * 1024 ;
96
@@ -12,7 +9,7 @@ fn main() {
129 // The pattern we want is a BufReader which wraps a Read impl where one Read::read call will
1310 // never fill the whole BufReader buffer.
1411 run_benchmark_group ( |group| {
15- define_benchmark ! ( group, bufreader_snappy, {
12+ group. register_benchmark ( " bufreader_snappy" , || {
1613 let data = vec ! [ 0u8 ; BYTES ] ;
1714 move || {
1815 let mut compressed = Vec :: new ( ) ;
Original file line number Diff line number Diff line change 11use benchlib;
22use benchlib:: benchmark:: run_benchmark_group;
3- use benchlib:: define_benchmark;
43
54fn main ( ) {
65 run_benchmark_group ( |group| {
76 // 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" , || {
98 let mut map = hashbrown:: HashMap :: with_capacity_and_hasher (
109 10000 ,
1110 fxhash:: FxBuildHasher :: default ( ) ,
Original file line number Diff line number Diff line change 22//! Code taken from https://github.com/prestontw/rust-nbody
33
44use benchlib:: benchmark:: run_benchmark_group;
5- use benchlib:: define_benchmark;
65
76mod nbody;
87
98fn main ( ) {
109 run_benchmark_group ( |group| {
11- define_benchmark ! ( group, nbody_10k, {
10+ group. register_benchmark ( " nbody_10k" , || {
1211 let mut nbody_10k = nbody:: init ( 10000 ) ;
1312 || {
1413 for _ in 0 ..10 {
You can’t perform that action at this time.
0 commit comments