pub struct ProcessSpan { /* private fields */ }Expand description
A tracked span of code that tracks process-wide allocations between creation and drop.
This span tracks allocations made by the entire process (all threads).
§Examples
use alloc_tracker::{Allocator, Operation, Session};
#[global_allocator]
static ALLOCATOR: Allocator<std::alloc::System> = Allocator::system();
let session = Session::new();
let mean_calc = session.operation("test");
{
let _span = mean_calc.measure_process();
// Perform some operation that allocates memory
let _data = String::from("Hello, world!");
} // Memory delta is automatically tracked and recorded hereImplementations§
Source§impl ProcessSpan
impl ProcessSpan
Sourcepub fn iterations(self, iterations: u64) -> Self
pub fn iterations(self, iterations: u64) -> Self
Sets the number of iterations for this span.
This allows you to specify how many iterations this span represents, which is used to calculate the mean allocation per iteration when the span is dropped.
§Examples
use alloc_tracker::{Allocator, Session};
#[global_allocator]
static ALLOCATOR: Allocator<std::alloc::System> = Allocator::system();
let session = Session::new();
let operation = session.operation("batch_work");
{
let _span = operation.measure_process().iterations(1000);
for _ in 0..1000 {
// Perform the same operation 1000 times
let _data = vec![42];
}
} // Total allocation is measured once and divided by 1000§Panics
Panics if iterations is zero.
Trait Implementations§
Source§impl Debug for ProcessSpan
impl Debug for ProcessSpan
Auto Trait Implementations§
impl Freeze for ProcessSpan
impl !RefUnwindSafe for ProcessSpan
impl Send for ProcessSpan
impl !Sync for ProcessSpan
impl Unpin for ProcessSpan
impl UnwindSafe for ProcessSpan
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