pub struct ResourceUsage {
pub instructions_executed: u64,
pub memory_bytes_allocated: u64,
pub output_bytes_written: u64,
/* private fields */
}Expand description
Tracks resource usage during VM execution.
Fields§
§instructions_executed: u64§memory_bytes_allocated: u64§output_bytes_written: u64Implementations§
Source§impl ResourceUsage
impl ResourceUsage
pub fn new(limits: ResourceLimits) -> Self
Sourcepub fn tick_instruction(&mut self) -> Result<(), ResourceLimitExceeded>
pub fn tick_instruction(&mut self) -> Result<(), ResourceLimitExceeded>
Check instruction count limit and amortized wall-time check. Called once per instruction in the dispatch loop.
Sourcepub fn record_allocation(
&mut self,
bytes: u64,
) -> Result<(), ResourceLimitExceeded>
pub fn record_allocation( &mut self, bytes: u64, ) -> Result<(), ResourceLimitExceeded>
Record memory allocation.
Sourcepub fn record_output(&mut self, bytes: u64) -> Result<(), ResourceLimitExceeded>
pub fn record_output(&mut self, bytes: u64) -> Result<(), ResourceLimitExceeded>
Record output bytes written.
Sourcepub fn limits(&self) -> &ResourceLimits
pub fn limits(&self) -> &ResourceLimits
Return current limits.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceUsage
impl RefUnwindSafe for ResourceUsage
impl Send for ResourceUsage
impl Sync for ResourceUsage
impl Unpin for ResourceUsage
impl UnsafeUnpin for ResourceUsage
impl UnwindSafe for ResourceUsage
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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