Macro test_generator::bench_expand_paths
source · bench_expand_paths!() { /* proc-macro */ }
Expand description
deprecated 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; "res/*" }
fn bench_exists(bencher: &mut test::Bencher, filename: &str) {
let path = std::path::Path::new(filename);
b.iter(|| { path.exists() });
}
}
Assuming "res/*"
expands to “res/set1”, and “res/set2” the macro will expand to
ⓘ
#[cfg(test)]
mod tests {
#[bench]
fn bench_exists_res_set1(bencher: & mut test::Bencher) {
bench_exists(bencher, "res/set1");
}
#[bench]
fn bench_exists_res_set2(bencher: & mut test::Bencher) {
bench_exists(bencher, "res/set2");
}
}