Struct calliper::ScenarioConfig
source · pub struct ScenarioConfig { /* private fields */ }
Expand description
Callgrind execution settings.
ScenarioConfig
defines scenario-agnostic
Implementations§
source§impl ScenarioConfig
impl ScenarioConfig
sourcepub fn valgrind(self, path: impl Into<String>) -> Self
pub fn valgrind(self, path: impl Into<String>) -> Self
Valgrind executable path. Default value: “valgrind”
sourcepub fn cache(self, settings: impl Into<Option<CacheOptions>>) -> Self
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});
sourcepub fn branch_sim(self, is_enabled: bool) -> Self
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.
sourcepub fn aslr(self, is_enabled: bool) -> Self
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.
sourcepub fn cleanup_files(self, is_enabled: bool) -> Self
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.
sourcepub fn collect_bus(self, is_enabled: bool) -> Self
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.
sourcepub fn filters(
self,
filters: impl IntoIterator<Item = impl Into<String>>
) -> Self
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.
sourcepub fn output(self, path: impl Into<String>) -> Self
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.
sourcepub fn get_valgrind(&self) -> &str
pub fn get_valgrind(&self) -> &str
Returns a path to valgrind.
sourcepub fn get_collect_bus(&self) -> bool
pub fn get_collect_bus(&self) -> bool
Returns true if event bus collection is switched on.
sourcepub fn get_cleanup_files(&self) -> bool
pub fn get_cleanup_files(&self) -> bool
Returns true if Callgrind file cleanup is switched on.
sourcepub fn get_aslr(&self) -> bool
pub fn get_aslr(&self) -> bool
Returns true if Address Space Layout Randomization is switched on.
sourcepub fn get_branch_sim(&self) -> bool
pub fn get_branch_sim(&self) -> bool
Returns true if branch predictor simulation is switched on.
sourcepub fn get_output_file(&self) -> Option<&str>
pub fn get_output_file(&self) -> Option<&str>
Returns the path to Callgrind output path if it was set manually by the user beforehand.
sourcepub fn get_filters(&self) -> &[String]
pub fn get_filters(&self) -> &[String]
Returns filters for a given scenario.
Trait Implementations§
source§impl Clone for ScenarioConfig
impl Clone for ScenarioConfig
source§fn clone(&self) -> ScenarioConfig
fn clone(&self) -> ScenarioConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ScenarioConfig
impl Debug for ScenarioConfig
source§impl Default for ScenarioConfig
impl Default for ScenarioConfig
source§fn default() -> ScenarioConfig
fn default() -> ScenarioConfig
source§impl<'de> Deserialize<'de> for ScenarioConfig
impl<'de> Deserialize<'de> for ScenarioConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Hash for ScenarioConfig
impl Hash for ScenarioConfig
source§impl PartialEq<ScenarioConfig> for ScenarioConfig
impl PartialEq<ScenarioConfig> for ScenarioConfig
source§fn eq(&self, other: &ScenarioConfig) -> bool
fn eq(&self, other: &ScenarioConfig) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ScenarioConfig> for ScenarioConfig
impl PartialOrd<ScenarioConfig> for ScenarioConfig
source§fn partial_cmp(&self, other: &ScenarioConfig) -> Option<Ordering>
fn partial_cmp(&self, other: &ScenarioConfig) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more