Struct soroban_env_host::cost_runner::CallRun
source · pub struct CallRun;
Implementations§
Trait Implementations§
source§impl CostRunner for CallRun
impl CostRunner for CallRun
§type SampleType = WasmInsnSample
type SampleType = WasmInsnSample
Data type of the sample running with.
§type RecycledType = (Option<RawVal>, <CallRun as CostRunner>::SampleType)
type RecycledType = (Option<RawVal>, <CallRun as CostRunner>::SampleType)
Data type to be recycled, this may include (but not limited to) the returned value and
unused samples. The main reason for recycling are 1. avoid unwanted memory deallocation
being counted as part of the run cost 2. prevent the optimizer from performing optimization
around unused value, making the bench deviate from the real case.
source§fn run_iter(
host: &Host,
_iter: u64,
sample: Self::SampleType
) -> Self::RecycledType
fn run_iter( host: &Host, _iter: u64, sample: Self::SampleType ) -> Self::RecycledType
Run a iteration of the
CostRunner
, called by run
for 0..RUN_ITERATIONS.
Execution under run_iter
is what’s actually being measured by the bench
machineary. Need to ensure as much as possible run_iter
only calls essential
host routines that go into the measurement. Any input setup needs to be done
beforehand and passed in via sample
.fn run_baseline_iter( host: &Host, _iter: u64, base_sample: Self::SampleType ) -> Self::RecycledType
source§const RUN_ITERATIONS: u64 = 100u64
const RUN_ITERATIONS: u64 = 100u64
Number of iterations to run, used to divide the resulting measured values.
Defaults to 100 to average out the measurement noises for fast-running cases.
If you find your measurements are finishing too slow, reduce this number.
source§fn run_baseline(
host: &Host,
samples: Vec<Self::SampleType>,
recycled: &mut Vec<Self::RecycledType>
)
fn run_baseline( host: &Host, samples: Vec<Self::SampleType>, recycled: &mut Vec<Self::RecycledType> )
Make sure
recycled
has been initialized with sufficient capacity needed to
store all the recycled value such that no allocation is triggered that will
polute the measurements.source§fn run(
host: &Host,
samples: Vec<Self::SampleType>,
recycled: &mut Vec<Self::RecycledType>
)
fn run( host: &Host, samples: Vec<Self::SampleType>, recycled: &mut Vec<Self::RecycledType> )
Run the
CostRunner
. This method is called under CPU-and-memory tracking
machinery, so anything that happens during it will be considered part of
the cost for running the HostMeasurement at the returned input. Will call
run_iter
with iter set to each number in 0..RUN_ITERATIONS.
Make sure recycled
has been initialized with sufficient capacity to store
all the recycled value such that no allocation is triggered that will polute
the measurements.source§fn get_total_input(host: &Host) -> u64
fn get_total_input(host: &Host) -> u64
Get the total input from this run. Default to asking the host. May be overridden
if host is not actually involved in the actual run. However, if overridden, there is
a risk of the computed input being diverged from the actual input from the host’s
perspective. So use it carefully. This should be after the
run
, outside of the
CPU-and-memory tracking machineary.Auto Trait Implementations§
impl RefUnwindSafe for CallRun
impl Send for CallRun
impl Sync for CallRun
impl Unpin for CallRun
impl UnwindSafe for CallRun
Blanket Implementations§
source§impl<T, U, E, C> Compare<(T, U)> for Cwhere
C: Compare<T, Error = E, Error = E> + Compare<U>,
impl<T, U, E, C> Compare<(T, U)> for Cwhere C: Compare<T, Error = E, Error = E> + Compare<U>,
source§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.