I am trying to assess one of my libraries’ (
emcee) performance. There is a low level function (
propose_stretch) which is called quite a few times, and performs some non-trivial code. I wish to benchmark this function, but it is not marked
pub - I do not forsee users of the library to call this function for themselves.
The problem is I’d like to keep my library running on stable rust, and the benchmarking system is nightly only. I current have a separate
benches subdirectory at the root of my project, which benchmarks a higher level, but public function. This works because normal compilation (on stable/beta) will ignore the
benches subdir during installation/testing for users of the crate.
To be able to benchmark the function in question, I have to move the benchmark functionality into the same file/module as the function - where currently I already have tests, but this will cause compilation to fail as I have to add:
#![feature(test)] extern crate test;
to the root of my crate, which will not compile on stable/beta.
I think I have these options:
- make the function public, which I would prefer not to do
- somehow add the lines above with a
nightlyfeature flag - and I do not know if one exists
- give up on benchmarking this function, as the caller function is benchmarked and the benchmark code is deterministic, however I would prefer to benchmark at a lower level
Apologies in advance if this is a problem with a known solution