[][src]Macro test_generator::bench_expand_paths

bench_expand_paths!() { /* proc-macro */ }

Generate a benchmark-function call for each file matching the pattern

extern crate test_generator;
#[cfg(test)]
mod tests {
  test_generator::bench_expand_paths! { bench_exists; "data/*" }

  fn bench_exists(bencher: &mut test::Bencher, filename: &str) {
       let path = std::path::Path::new(filename);
       b.iter(|| { path.exists() });
   }
}

Assuming "data/*" expands to "data/set1", and "data/set2" the macro will expand to

mod tests {
    #[bench]
    fn bench_exists_data_set1(bencher: & mut test::Bencher) {
        bench_exists(bencher, "data/set1");
    }

    #[bench]
    fn bench_exists_data_set2(bencher: & mut test::Bencher) {
        bench_exists(bencher, "data/set2");
    }
}