Это возможно.
Посмотрите на Критерий критерия .Там вы можете найти методы, относящиеся к вам, в частности measurement_time
.
Копая глубже, вы можете найти, как их использовать здесь :
fn bench(c: &mut Criterion) {
// Setup (construct data, allocate memory, etc)
c.bench(
"routines",
Benchmark::new("routine_1", |b| b.iter(|| routine_1()))
.with_function("routine_2", |b| b.iter(|| routine_2()))
.measurement_time(Duration::from_millis(1000))
);
}
criterion_group!(benches, bench);
criterion_main!(benches);
Где measurement_time(Duration::from_millis(1000))
- искомый дроид.Это фактически уменьшило количество итераций для моей конкретной функции на 80%.