pub struct FlamegraphConfig(/* private fields */);
default
only.Expand description
The FlamegraphConfig
which allows the customization of the created flamegraphs
Callgrind flamegraphs are very similar to callgrind_annotate
output. In contrast to
callgrind_annotate
text based output, the produced flamegraphs are svg files (located in the
target/iai
directory) which can be viewed in a browser.
§Experimental
Note the following considerations only affect flamegraphs of multi-threaded/multi-process benchmarks and benchmarks which produce multiple parts with a total over all sub-metrics.
Currently, Iai-Callgrind creates the flamegraphs only for the total over all threads/parts and subprocesses. This leads to complications since the call graph is not be fully recovered just by examining each thread/subprocess separately. So, the total metrics in the flamegraphs might not be the same as the total metrics shown in the terminal output. If in doubt, the terminal output shows the the correct metrics.
§Examples
use iai_callgrind::{LibraryBenchmarkConfig, FlamegraphConfig, main};
main!(
config = LibraryBenchmarkConfig::default()
.flamegraph(FlamegraphConfig::default());
library_benchmark_groups = some_group
);
Implementations§
source§impl FlamegraphConfig
impl FlamegraphConfig
sourcepub fn kind(&mut self, kind: FlamegraphKind) -> &mut Self
pub fn kind(&mut self, kind: FlamegraphKind) -> &mut Self
Option to change the FlamegraphKind
The default is FlamegraphKind::All
.
§Examples
For example, to only create a differential flamegraph:
use iai_callgrind::{FlamegraphConfig, FlamegraphKind};
let config = FlamegraphConfig::default().kind(FlamegraphKind::Differential);
sourcepub fn negate_differential(&mut self, negate_differential: bool) -> &mut Self
pub fn negate_differential(&mut self, negate_differential: bool) -> &mut Self
Negate the differential flamegraph FlamegraphKind::Differential
The default is false
.
Instead of showing the differential flamegraph from the viewing angle of what has happened the negated differential flamegraph shows what will happen. Especially, this allows to see vanished event lines (in blue) for example because the underlying code has improved and removed an unnecessary function call.
See also Differential Flame Graphs from Brendan Gregg’s Blog.
§Examples
use iai_callgrind::{FlamegraphConfig, FlamegraphKind};
let config = FlamegraphConfig::default().negate_differential(true);
sourcepub fn normalize_differential(
&mut self,
normalize_differential: bool,
) -> &mut Self
pub fn normalize_differential( &mut self, normalize_differential: bool, ) -> &mut Self
Normalize the differential flamegraph
This’ll make the first profile event count to match the second. This’ll help in situations when everything looks read (or blue) to get a balanced profile with the full red/blue spectrum
§Examples
use iai_callgrind::{FlamegraphConfig, FlamegraphKind};
let config = FlamegraphConfig::default().normalize_differential(true);
sourcepub fn event_kinds<T>(&mut self, event_kinds: T) -> &mut Selfwhere
T: IntoIterator<Item = EventKind>,
pub fn event_kinds<T>(&mut self, event_kinds: T) -> &mut Selfwhere
T: IntoIterator<Item = EventKind>,
One or multiple EventKind
for which a flamegraph is going to be created.
The default is EventKind::Ir
Currently, flamegraph creation is limited to one flamegraph for each EventKind
and
there’s no way to merge all event kinds into a single flamegraph.
Note it is an error to specify a EventKind
which isn’t recorded by callgrind. See the
docs of the variants of EventKind
which callgrind option is needed to create a record
for it. See also the Callgrind
Documentation. The
EventKind
s recorded by callgrind which are available as long as the cache simulation is
turned on with --cache-sim=yes
(which is the default):
EventKind::Ir
EventKind::Dr
EventKind::Dw
EventKind::I1mr
EventKind::ILmr
EventKind::D1mr
EventKind::DLmr
EventKind::D1mw
EventKind::DLmw
If the cache simulation is turned on, the following derived EventKinds
are also available:
EventKind::L1hits
EventKind::LLhits
EventKind::RamHits
EventKind::TotalRW
EventKind::EstimatedCycles
§Examples
use iai_callgrind::{EventKind, FlamegraphConfig};
let config =
FlamegraphConfig::default().event_kinds([EventKind::EstimatedCycles, EventKind::Ir]);
sourcepub fn direction(&mut self, direction: Direction) -> &mut Self
pub fn direction(&mut self, direction: Direction) -> &mut Self
Set the Direction
in which the flamegraph should grow.
The default is Direction::TopToBottom
.
§Examples
For example to change the default
use iai_callgrind::{Direction, FlamegraphConfig};
let config = FlamegraphConfig::default().direction(Direction::BottomToTop);
sourcepub fn title(&mut self, title: String) -> &mut Self
pub fn title(&mut self, title: String) -> &mut Self
Overwrite the default title of the final flamegraph
§Examples
use iai_callgrind::{Direction, FlamegraphConfig};
let config = FlamegraphConfig::default().title("My flamegraph title".to_owned());
sourcepub fn subtitle(&mut self, subtitle: String) -> &mut Self
pub fn subtitle(&mut self, subtitle: String) -> &mut Self
Overwrite the default subtitle of the final flamegraph
§Examples
use iai_callgrind::FlamegraphConfig;
let config = FlamegraphConfig::default().subtitle("My flamegraph subtitle".to_owned());
sourcepub fn min_width(&mut self, min_width: f64) -> &mut Self
pub fn min_width(&mut self, min_width: f64) -> &mut Self
Set the minimum width (in pixels) for which event lines are going to be shown.
The default is 0.1
To show all events, set the min_width
to 0f64
.
§Examples
use iai_callgrind::FlamegraphConfig;
let config = FlamegraphConfig::default().min_width(0f64);
Trait Implementations§
source§impl AsRef<FlamegraphConfig> for FlamegraphConfig
impl AsRef<FlamegraphConfig> for FlamegraphConfig
source§fn as_ref(&self) -> &InternalFlamegraphConfig
fn as_ref(&self) -> &InternalFlamegraphConfig
source§impl Clone for FlamegraphConfig
impl Clone for FlamegraphConfig
source§fn clone(&self) -> FlamegraphConfig
fn clone(&self) -> FlamegraphConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FlamegraphConfig
impl Debug for FlamegraphConfig
source§impl Default for FlamegraphConfig
impl Default for FlamegraphConfig
source§fn default() -> FlamegraphConfig
fn default() -> FlamegraphConfig
source§impl From<&FlamegraphConfig> for InternalFlamegraphConfig
impl From<&FlamegraphConfig> for InternalFlamegraphConfig
source§fn from(value: &FlamegraphConfig) -> Self
fn from(value: &FlamegraphConfig) -> Self
source§impl From<&mut FlamegraphConfig> for InternalFlamegraphConfig
impl From<&mut FlamegraphConfig> for InternalFlamegraphConfig
source§fn from(value: &mut FlamegraphConfig) -> Self
fn from(value: &mut FlamegraphConfig) -> Self
source§impl From<FlamegraphConfig> for InternalFlamegraphConfig
impl From<FlamegraphConfig> for InternalFlamegraphConfig
source§fn from(value: FlamegraphConfig) -> Self
fn from(value: FlamegraphConfig) -> Self
Auto Trait Implementations§
impl Freeze for FlamegraphConfig
impl RefUnwindSafe for FlamegraphConfig
impl Send for FlamegraphConfig
impl Sync for FlamegraphConfig
impl Unpin for FlamegraphConfig
impl UnwindSafe for FlamegraphConfig
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)