Benchmark test organisation

Hi Guys,
could you help me how to organize my tests + benches in my project?

I use the test crate for bench tests, and currently I place all the unit tests and benches in the same part

#[cfg(test)]
mod tests {
    use super::*;
    use rand::prelude::*;
    use test::Bencher;
    #[test]
    fn test_sample() {
        ...
    }
    #[bench]
    fn bench_sample(b: &mut Bencher) {
        ...
    }
}

My issue:

  • when I run cargo test, it also runs benches, but inside a bench I use big test structs, to bench my functions. To build up these test variables takes time, of course this init process is not the part of the bench iter, but it parts of the bench and when running test, it takes a lot of time, usually it does not finish as it takes longer then 60 sec.

My question

How to organize my tests where to place unit tests and where to place benches, and how can I avoid running benches in test mode?

Thank you in advance,
Best wishes,
Peter Mezei.

Currently my only option is to run test by defining cargo test test_, and naming all the test starting with test_

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.