pub struct ScenarioConfig { /* private fields */ }
Expand description

Callgrind execution settings.

ScenarioConfig defines scenario-agnostic

Implementations§

source§

impl ScenarioConfig

source

pub fn valgrind(self, path: impl Into<String>) -> Self

Valgrind executable path. Default value: “valgrind”

source

pub fn cache(self, settings: impl Into<Option<CacheOptions>>) -> Self

Configuration of cache simulation. Callgrind can collect basic metrics on CPU cache usage of your program. Calliper does not enable that behaviour by default - cache metrics collection can be enabled by passing Some(CacheOptions) object (which corresponds to passing --cache-sim=yes to Callgrind).

use calliper::{ScenarioConfig, CacheOptions, CacheParameters};

// Scenarios do not enable cache simulation by default.
let config_without_cache = ScenarioConfig::default();
// By default, cache options use current CPU's cache parameters.
let config_with_native_cache = ScenarioConfig::default().cache(CacheOptions::default());
// For best benchmark reproducability across different machines, it is recommended to set cache sizes manually.
let first_level_data = Some(CacheParameters { size: 32768, associativity: 8, line_size: 8 });
let first_level_code = first_level_data.clone();
let last_level = Some(CacheParameters { size: 12582912, associativity: 8, line_size: 8});
let config_with_handtuned_cache = ScenarioConfig::default().cache(CacheOptions { first_level_data, first_level_code, last_level});
source

pub fn branch_sim(self, is_enabled: bool) -> Self

Sets branch prediction simulation. Mirrors Callgrind’s --branch-sim option. Collected metrics include number of executed conditional branches and related predictor misses, executed indirect jumps and related misses of the jump address predictor. Defaults to false.

source

pub fn aslr(self, is_enabled: bool) -> Self

If set to true, Address Space Layout Randomization (ASLR) will be enabled. ASLR is a security measure to prevent certain classes of exploits. It can skew benchmark results by making them less deterministic. It is recommended to keep this turned off. Defaults to false.

source

pub fn cleanup_files(self, is_enabled: bool) -> Self

If set to true, Callgrind output for this scenario will be cleared up. Defaults to true.

source

pub fn collect_bus(self, is_enabled: bool) -> Self

Sets bus event collection (counts number of executed atomic instructions). Corresponds to --collect-bus Callgrind option. Defaults to false.

source

pub fn filters( self, filters: impl IntoIterator<Item = impl Into<String>> ) -> Self

Set filters for a particular scenario. Corresponds to --toggle-collect. Excerpt from Callgrind documentation: “Further, you can limit event collection to a specific function by using –toggle-collect=function. This will toggle the collection state on entering and leaving the specified function. … Only events happening while running inside of the given function will be collected. Recursive calls of the given function do not trigger any action. This option can be given multiple times to specify different functions of interest.”

Defaults to name of benchmarked function. Filtering can be disabled by passing in an empty vector, though be aware that then whole program will be under benchmark - including Calliper code. This is most likely not what you want.

source

pub fn output(self, path: impl Into<String>) -> Self

Sets callgrind file output path. Defaults to callgrind.out.{pid}, where pid is - naturally - not up to us anyhow. If you intend to process Callgrind’s results further, it is recommended to set the path manually.

source

pub fn get_valgrind(&self) -> &str

Returns a path to valgrind.

source

pub fn get_collect_bus(&self) -> bool

Returns true if event bus collection is switched on.

source

pub fn get_cleanup_files(&self) -> bool

Returns true if Callgrind file cleanup is switched on.

source

pub fn get_aslr(&self) -> bool

Returns true if Address Space Layout Randomization is switched on.

source

pub fn get_branch_sim(&self) -> bool

Returns true if branch predictor simulation is switched on.

source

pub fn get_output_file(&self) -> Option<&str>

Returns the path to Callgrind output path if it was set manually by the user beforehand.

source

pub fn get_filters(&self) -> &[String]

Returns filters for a given scenario.

Trait Implementations§

source§

impl Clone for ScenarioConfig

source§

fn clone(&self) -> ScenarioConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ScenarioConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ScenarioConfig

source§

fn default() -> ScenarioConfig

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ScenarioConfig

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Hash for ScenarioConfig

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<ScenarioConfig> for ScenarioConfig

source§

fn eq(&self, other: &ScenarioConfig) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<ScenarioConfig> for ScenarioConfig

source§

fn partial_cmp(&self, other: &ScenarioConfig) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for ScenarioConfig

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for ScenarioConfig

source§

impl StructuralEq for ScenarioConfig

source§

impl StructuralPartialEq for ScenarioConfig

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,