Skip to content

Commit

Permalink
add inline color scheme for flamegraph
Browse files Browse the repository at this point in the history
this colorscheme colors inlined functions in a violet shade while normal
functions are colored green
  • Loading branch information
lievenhey committed Dec 7, 2023
1 parent 64c93f9 commit 45192e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/flamegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ QBrush brushKernel(const Data::Symbol& symbol)
return user;
}

QBrush brushInline(const Data::Symbol& symbol)
{
static auto inlineBrush = QBrush(QColor(88, 53, 94, 125));
static auto normalBrush = QBrush(QColor(214, 244, 183, 125));

return symbol.isInline ? inlineBrush : normalBrush;
}

bool isInPathList(const QStringList& paths, const QString& subPath)
{
auto containsSubPath = [subPath](const auto& path) { return subPath.startsWith(path); };
Expand Down Expand Up @@ -406,6 +414,8 @@ QBrush brush(const Data::Symbol& entry, Settings::ColorScheme scheme, quint32 co
return brushKernel(entry);
case Settings::ColorScheme::System:
return brushSystem(entry);
case Settings::ColorScheme::Inline:
return brushInline(entry);
case Settings::ColorScheme::Default:
return brushImpl(qHash(entry), BrushType::Hot);
case Settings::ColorScheme::CostRatio:
Expand Down Expand Up @@ -734,6 +744,7 @@ FlameGraph::FlameGraph(QWidget* parent, Qt::WindowFlags flags)
comboBox->addItem(tr("Binary"), QVariant::fromValue(Settings::ColorScheme::Binary));
comboBox->addItem(tr("Kernel"), QVariant::fromValue(Settings::ColorScheme::Kernel));
comboBox->addItem(tr("System"), QVariant::fromValue(Settings::ColorScheme::System));
comboBox->addItem(tr("Inline"), QVariant::fromValue(Settings::ColorScheme::Inline));
comboBox->addItem(tr("Cost Ratio"), QVariant::fromValue(Settings::ColorScheme::CostRatio));

auto setColorScheme = [this](Settings::ColorScheme scheme) {
Expand Down
1 change: 1 addition & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Settings : public QObject
Binary,
Kernel,
System,
Inline,
CostRatio,
NumColorSchemes
};
Expand Down

0 comments on commit 45192e2

Please sign in to comment.