pub struct RunMeta { /* private fields */ }Expand description
Informs a benchmark run callback about the basic metadata associated with the run.
This type is passed to various callback functions during benchmark execution, providing information about the current thread group, total number of groups, and iteration count. This allows callbacks to behave differently based on their context within the benchmark run.
§Examples
use many_cpus::ProcessorSet;
use par_bench::{Run, ThreadPool};
use new_zealand::nz;
let mut pool = ThreadPool::new(&processors);
let run = Run::new()
.groups(nz!(2)) // 2 groups of 2 threads each
.prepare_thread(|args| {
println!("Thread in group {} of {}",
args.meta().group_index(),
args.meta().group_count());
println!("Will execute {} iterations", args.meta().iterations());
// Return different state based on group
if args.meta().group_index() == 0 {
"reader_thread"
} else {
"writer_thread"
}
})
.prepare_iter(|args| *args.thread_state())
.iter(|mut args| {
let thread_type = args.take_iter_state();
match thread_type {
"reader_thread" => { /* reader work */ },
"writer_thread" => { /* writer work */ },
_ => unreachable!(),
}
});
let _results = run.execute_on(&mut pool, 100);Implementations§
Source§impl RunMeta
impl RunMeta
Sourcepub fn group_index(&self) -> usize
pub fn group_index(&self) -> usize
The index of the current thread group, starting from 0.
Sourcepub fn group_count(&self) -> NonZero<usize>
pub fn group_count(&self) -> NonZero<usize>
The total number of thread groups in the run.
Sourcepub fn thread_count(&self) -> NonZero<usize>
pub fn thread_count(&self) -> NonZero<usize>
The total number of threads used to execute the run.
Sourcepub fn iterations(&self) -> u64
pub fn iterations(&self) -> u64
How many iterations will be executed as part of this run.
Trait Implementations§
impl Copy for RunMeta
impl Eq for RunMeta
impl StructuralPartialEq for RunMeta
Auto Trait Implementations§
impl Freeze for RunMeta
impl RefUnwindSafe for RunMeta
impl Send for RunMeta
impl Sync for RunMeta
impl Unpin for RunMeta
impl UnwindSafe for RunMeta
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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