initialization code
Hello,
I'm looking to run some initialization once before starting any benchmarks. How do I do this? Thanks!
I found my answer for criterion here: https://www.reddit.com/r/rust/comments/8uj5oa/criterion_benchmark_with_onetime_setup_also_how/ (btw it would be nice to have that answer in the FAQ), but I'm wondering about how to do that in iai.
ok my undersrtanding is that the function is actually called a single time, so you can have the init function be part of it? Still, it'd be nice not to have that be part of the bench
fn bench_proof_creation() {
// init code here
// bench code here
}
iai::main!(bench_proof_creation);
the README actually states this:
Con: Iai cannot exclude setup code from the measurements, where Criterion-rs can.
so perhaps a good way to exclude setup code is to bench the setup_code in addition of benching setup_code + stuff and then subtract.
I set up an image buffer by storing it in a static, then obtaining a reference to it at runtime is effectively free. What setup are you doing at runtime?
I'm initializing a large structs with a bug of vectors in it :o I guess I could serialize it, but then changing the code would break the serialization