Struct soroban_sdk::testutils::budget::Budget
source · pub struct Budget(_);
Available on crate feature
testutils
only.Expand description
Budget that tracks the resources consumed for the environment.
The budget consistents of two cost dimensions:
- CPU instructions
- Memory
Inputs feed into those cost dimensions.
Note that all cost dimensions – CPU instructions, memory – and the VM cost type inputs are likely to be underestimated when running Rust code compared to running the WASM equivalent.
Examples
use soroban_sdk::{Env, Symbol};
env.budget().reset();
// ...
println!("{}", env.budget());
Implementations§
source§impl Budget
impl Budget
sourcepub fn cpu_instruction_cost(&self) -> u64
pub fn cpu_instruction_cost(&self) -> u64
Returns the CPU instruction cost.
Note that CPU instructions are likely to be underestimated when running Rust code compared to running the WASM equivalent.
sourcepub fn memory_bytes_cost(&self) -> u64
pub fn memory_bytes_cost(&self) -> u64
Returns the memory cost.
Note that memory is likely to be underestimated when running Rust code compared to running the WASM equivalent.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Budget
impl !Send for Budget
impl !Sync for Budget
impl Unpin for Budget
impl !UnwindSafe for Budget
Blanket Implementations§
§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.