Skip to main content

Flame graph

info

Charts are available with Avalonia Pro.

Flame graphs display hierarchical cost, duration, or sample data as stacked rectangles, with the root at the bottom and deeper calls above it.

When to use

  • Profiler output: Show CPU, memory, or duration hot spots in a call tree.
  • Trace inspection: Understand where time accumulates in nested operations.
  • Hierarchical cost review: Compare depth and width across expensive branches.

Code example

XAML

<charts:FlameGraph Title="CPU profile"
Height="320"
ItemsSource="{Binding StackTraceData}"
ValuePath="Duration"
LabelPath="MethodName"
ChildrenPath="SubCalls" />

Data model (C#)

public class FlameNode
{
public string MethodName { get; set; } = string.Empty;
public double Duration { get; set; }
public ObservableCollection<FlameNode> SubCalls { get; set; } = new();
}

public ObservableCollection<FlameNode> StackTraceData { get; } = new()
{
new FlameNode
{
MethodName = "Program.Main",
Duration = 2000,
SubCalls =
{
new FlameNode
{
MethodName = "App.OnFrameworkInitializationCompleted",
Duration = 1950,
SubCalls =
{
new FlameNode { MethodName = "App.Initialize", Duration = 50 },
new FlameNode { MethodName = "Window.Show", Duration = 100 },
new FlameNode { MethodName = "Dispatcher.MainLoop", Duration = 1800 }
}
}
}
}
};

Common properties

PropertyDescriptionDefault
ItemsSourceRoot collection for the flame graph.null
ValuePathPath to the value that controls rectangle width.null
LabelPathPath to the item label.null
ChildrenPathPath to the child collection.null

See also