pub struct ScopedAllocCounter { /* private fields */ }
Expand description
A simple struct that counts the number of bytes allocated and deallocated in a scope.
Implementations§
Source§impl ScopedAllocCounter
impl ScopedAllocCounter
pub fn new() -> Self
Sourcepub fn get_allocated(&self) -> usize
pub fn get_allocated(&self) -> usize
Returns the total number of bytes allocated in the current scope
since the creation of this ScopedAllocCounter
.
§Example
use cu29_runtime::monitoring::ScopedAllocCounter;
let counter = ScopedAllocCounter::new();
let _vec = vec![0u8; 1024];
println!("Bytes allocated: {}", counter.get_allocated());
Sourcepub fn get_deallocated(&self) -> usize
pub fn get_deallocated(&self) -> usize
Returns the total number of bytes deallocated in the current scope
since the creation of this ScopedAllocCounter
.
§Example
use cu29_runtime::monitoring::ScopedAllocCounter;
let counter = ScopedAllocCounter::new();
let _vec = vec![0u8; 1024];
drop(_vec);
println!("Bytes deallocated: {}", counter.get_deallocated());
Trait Implementations§
Source§impl Default for ScopedAllocCounter
impl Default for ScopedAllocCounter
Auto Trait Implementations§
impl Freeze for ScopedAllocCounter
impl RefUnwindSafe for ScopedAllocCounter
impl Send for ScopedAllocCounter
impl Sync for ScopedAllocCounter
impl Unpin for ScopedAllocCounter
impl UnwindSafe for ScopedAllocCounter
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