pub trait Benchmark {
type Args: Clone;
// Required methods
fn prepare(&self) -> Self::Args;
fn execute(&self, args: Self::Args);
fn name(&self) -> String;
fn sync(&self);
// Provided methods
fn num_samples(&self) -> usize { ... }
fn options(&self) -> Option<String> { ... }
fn shapes(&self) -> Vec<Vec<usize>> { ... }
fn profile(&self, args: Self::Args) -> ProfileDuration { ... }
fn profile_full(&self, args: Self::Args) -> ProfileDuration { ... }
fn run(&self, timing_method: TimingMethod) -> BenchmarkDurations { ... }
}
Expand description
Benchmark trait.
Required Associated Types§
Required Methods§
Sourcefn prepare(&self) -> Self::Args
fn prepare(&self) -> Self::Args
Prepare the benchmark, run anything that is essential for the benchmark, but shouldn’t count as included in the duration.
§Notes
This should not include warmup, the benchmark will be run at least one time without measuring the execution time.
Sourcefn execute(&self, args: Self::Args)
fn execute(&self, args: Self::Args)
Execute the benchmark and returns the time it took to complete.
Provided Methods§
Sourcefn num_samples(&self) -> usize
fn num_samples(&self) -> usize
Number of samples per run required to have a statistical significance.
Sourcefn profile(&self, args: Self::Args) -> ProfileDuration
fn profile(&self, args: Self::Args) -> ProfileDuration
Start measuring the computation duration.
Sourcefn profile_full(&self, args: Self::Args) -> ProfileDuration
fn profile_full(&self, args: Self::Args) -> ProfileDuration
Start measuring the computation duration. Use the full duration irregardless of whether device duration is available or not.
Sourcefn run(&self, timing_method: TimingMethod) -> BenchmarkDurations
fn run(&self, timing_method: TimingMethod) -> BenchmarkDurations
Run the benchmark a number of times.