Struct iai_callgrind::Arg
source · pub struct Arg(/* private fields */);
Expand description
The arguments needed for Run
which are passed to the benchmarked binary
Implementations§
source§impl Arg
impl Arg
sourcepub fn new<T, I, U>(id: T, args: U) -> Self
pub fn new<T, I, U>(id: T, args: U) -> Self
Create a new Arg
.
The id
must be unique within the same group. It’s also possible to use BenchmarkId
as
an argument for the id
if you want to create unique ids from a parameter.
An Arg
can contain multiple arguments which are passed to the benchmarked binary as is. In
the case of no arguments at all, it’s more convenient to use Arg::empty
.
Examples
use iai_callgrind::{binary_benchmark_group, Arg, BinaryBenchmarkGroup, Run};
use std::ffi::OsStr;
binary_benchmark_group!(
name = my_exe_group;
benchmark = |"my-exe", group: &mut BinaryBenchmarkGroup| {
group.bench(Run::with_arg(Arg::new("foo", &["foo"])));
group.bench(Run::with_arg(Arg::new("foo bar", &["foo", "bar"])));
group.bench(Run::with_arg(Arg::new("os str foo", &[OsStr::new("foo")])));
}
);
Here’s a short example which makes use of the BenchmarkId
to generate unique ids for
each Arg
:
use iai_callgrind::{binary_benchmark_group, Arg, BinaryBenchmarkGroup, Run, BenchmarkId};
use std::ffi::OsStr;
binary_benchmark_group!(
name = my_exe_group;
benchmark = |"my-exe", group: &mut BinaryBenchmarkGroup| {
for i in 0..10 {
group.bench(Run::with_arg(
Arg::new(BenchmarkId::new("foo with", i), [format!("--foo={i}")])
));
}
}
);
sourcepub fn empty<T>(id: T) -> Self
pub fn empty<T>(id: T) -> Self
Create a new Arg
with no arguments for the benchmarked binary
See also Arg::new
Examples
use iai_callgrind::{binary_benchmark_group, Arg, BinaryBenchmarkGroup, Run};
binary_benchmark_group!(
name = my_exe_group;
benchmark = |"my-exe", group: &mut BinaryBenchmarkGroup| {
group.bench(Run::with_arg(Arg::empty("empty foo")));
}
);
Trait Implementations§
source§impl From<&Arg> for InternalArg
impl From<&Arg> for InternalArg
source§impl From<&mut Arg> for InternalArg
impl From<&mut Arg> for InternalArg
Auto Trait Implementations§
impl RefUnwindSafe for Arg
impl Send for Arg
impl Sync for Arg
impl Unpin for Arg
impl UnwindSafe for Arg
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
Mutably borrows from an owned value. Read more