use std::time::Duration;
use crate::{counter::CounterSet, time::FineDuration};
#[derive(Clone, Default)]
pub struct BenchOptions {
pub sample_count: Option<u32>,
pub sample_size: Option<u32>,
pub threads: Option<&'static [usize]>,
pub counters: CounterSet,
pub min_time: Option<Duration>,
pub max_time: Option<Duration>,
pub skip_ext_time: Option<bool>,
pub ignore: Option<bool>,
}
impl BenchOptions {
#[must_use]
pub(crate) fn overwrite(&self, other: &Self) -> Self {
Self {
sample_count: self.sample_count.or(other.sample_count),
sample_size: self.sample_size.or(other.sample_size),
threads: self.threads.or(other.threads),
min_time: self.min_time.or(other.min_time),
max_time: self.max_time.or(other.max_time),
skip_ext_time: self.skip_ext_time.or(other.skip_ext_time),
ignore: self.ignore.or(other.ignore),
counters: self.counters.overwrite(&other.counters),
}
}
#[inline]
pub(crate) fn has_samples(&self) -> bool {
self.sample_count != Some(0) && self.sample_size != Some(0)
}
#[inline]
pub(crate) fn min_time(&self) -> FineDuration {
self.min_time.map(FineDuration::from).unwrap_or_default()
}
#[inline]
pub(crate) fn max_time(&self) -> FineDuration {
self.max_time.map(FineDuration::from).unwrap_or(FineDuration::MAX)
}
}