pub struct FuchsiaCriterion { /* private fields */ }Expand description
Thin wrapper around Criterion.
Implementations§
Source§impl FuchsiaCriterion
impl FuchsiaCriterion
Sourcepub fn fuchsia_bench() -> Self
pub fn fuchsia_bench() -> Self
Creates a new Criterion object whose output is tailored to Fuchsia-CI.
It calls its Default::default constructor with 10,000 resamples, then looks for a CMD
argument providing the path for JSON file where the micro-benchmark results should be
written (in the Fuchsiaperf file format).
Sourcepub fn fuchsia_bench_with_args(args: &[&str]) -> Self
pub fn fuchsia_bench_with_args(args: &[&str]) -> Self
Same as fuchsia_bench(), but parses the specified args instead of parsing
std::env::args.
This is useful when the benchmarks needs to accept some arguments specified in the CML file.
Methods from Deref<Target = Criterion>§
Sourcepub fn benchmark_group<S>(&mut self, group_name: S) -> BenchmarkGroup<'_, M>
pub fn benchmark_group<S>(&mut self, group_name: S) -> BenchmarkGroup<'_, M>
Return a benchmark group. All benchmarks performed using a benchmark group will be grouped together in the final report.
§Examples:
use criterion::{criterion_group, criterion_main, Criterion};
fn bench_simple(c: &mut Criterion) {
let mut group = c.benchmark_group("My Group");
// Now we can perform benchmarks with this group
group.bench_function("Bench 1", |b| b.iter(|| 1 ));
group.bench_function("Bench 2", |b| b.iter(|| 2 ));
group.finish();
}
criterion_group!(benches, bench_simple);
criterion_main!(benches);§Panics:
Panics if the group name is empty
Sourcepub fn bench_function<F>(&mut self, id: &str, f: F) -> &mut Criterion<M>
pub fn bench_function<F>(&mut self, id: &str, f: F) -> &mut Criterion<M>
Benchmarks a function. For comparing multiple functions, see
benchmark_group.
§Example
use criterion::{criterion_group, criterion_main, Criterion};
fn bench(c: &mut Criterion) {
// Setup (construct data, allocate memory, etc)
c.bench_function(
"function_name",
|b| b.iter(|| {
// Code to benchmark goes here
}),
);
}
criterion_group!(benches, bench);
criterion_main!(benches);Sourcepub fn bench_with_input<F, I>(
&mut self,
id: BenchmarkId,
input: &I,
f: F,
) -> &mut Criterion<M>
pub fn bench_with_input<F, I>( &mut self, id: BenchmarkId, input: &I, f: F, ) -> &mut Criterion<M>
Benchmarks a function with an input. For comparing multiple functions or multiple inputs,
see benchmark_group.
§Example
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
fn bench(c: &mut Criterion) {
// Setup (construct data, allocate memory, etc)
let input = 5u64;
c.bench_with_input(
BenchmarkId::new("function_name", input), &input,
|b, i| b.iter(|| {
// Code to benchmark using input `i` goes here
}),
);
}
criterion_group!(benches, bench);
criterion_main!(benches);Trait Implementations§
Source§impl Default for FuchsiaCriterion
impl Default for FuchsiaCriterion
Source§impl Deref for FuchsiaCriterion
impl Deref for FuchsiaCriterion
Source§impl DerefMut for FuchsiaCriterion
impl DerefMut for FuchsiaCriterion
Source§impl Drop for FuchsiaCriterion
impl Drop for FuchsiaCriterion
Source§fn drop(&mut self)
fn drop(&mut self)
Drops the Criterion wrapper.
If initialized with FuchsiaCriterion::fuchsia_bench, it will write the Fuchsia-specific
JSON file before dropping.
Auto Trait Implementations§
impl !Freeze for FuchsiaCriterion
impl !RefUnwindSafe for FuchsiaCriterion
impl !Send for FuchsiaCriterion
impl !Sync for FuchsiaCriterion
impl !UnwindSafe for FuchsiaCriterion
impl Unpin for FuchsiaCriterion
impl UnsafeUnpin for FuchsiaCriterion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more