I was trying to use the "bencher" framework to write benchmarks for my own codebase. However, I couldn't quite get the benchmark file to recognize functions defined in my src folder. For example, I've a file in src/lib.rs
and defined a struct pub struct Foo
there. Then, how do I use the struct Foo
in benches/example.rs
? I tried with extern crate
with my package name and use lib::...
, but neither works...
Edit: actually the above is not all correct: I don't have a lib.rs file and my struct was defined in src/lib/core.rs. I provided a minimal example project called bench_example
below. The file tree looks like:
bench_example
- src
- main.rs
- lib
- core.rs
- mod.rs
- benches
- example.rs
In "main.rs" I simply have a mod lib;
statement. Similarly, in "mod.rs" I just have mod core;
Then, in "core.rs" I have a definition struct Foo{}
The problem is when I try to use the Foo
struct in the benchmark file below:
"benches/example.rs":
use bencher::{benchmark_group, benchmark_main, Bencher};
use bench_example::lib::core::Bar;
pub fn a(b: &mut Bencher){
let _ = Bar{};
}
benchmark_group!(benches, a);
benchmark_main!(benches);