summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-02 21:37:19 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-02 23:05:04 +0100
commit8effe0b632066715216bb88bb7213dd3601426de (patch)
tree1fdf68745f1447e019784928d4cc777f0f147293
parent8e8e8c801ce97b3f519c4a123e448f2cceb278a2 (diff)
downloadserenity-8effe0b632066715216bb88bb7213dd3601426de.zip
ProfileView: Show "self" sample counts in profiles
The "self" sample count is the number of samples that had this specific frame as its innermost stack frame (leaf nodes in the profile tree.)
-rw-r--r--DevTools/ProfileViewer/Profile.cpp8
-rw-r--r--DevTools/ProfileViewer/Profile.h3
-rw-r--r--DevTools/ProfileViewer/ProfileModel.cpp6
-rw-r--r--DevTools/ProfileViewer/ProfileModel.h1
4 files changed, 14 insertions, 4 deletions
diff --git a/DevTools/ProfileViewer/Profile.cpp b/DevTools/ProfileViewer/Profile.cpp
index bc8ce4f2b8..07071ecc94 100644
--- a/DevTools/ProfileViewer/Profile.cpp
+++ b/DevTools/ProfileViewer/Profile.cpp
@@ -117,18 +117,18 @@ void Profile::rebuild_tree()
{
if (!m_inverted) {
for (size_t i = 0; i < event.frames.size(); ++i) {
- if (callback(event.frames.at(i)) == IterationDecision::Break)
+ if (callback(event.frames.at(i), i == event.frames.size() - 1) == IterationDecision::Break)
break;
}
} else {
for (ssize_t i = event.frames.size() - 1; i >= 0; --i) {
- if (callback(event.frames.at(i)) == IterationDecision::Break)
+ if (callback(event.frames.at(i), static_cast<size_t>(i) == event.frames.size() - 1) == IterationDecision::Break)
break;
}
}
};
- for_each_frame([&](const Frame& frame) {
+ for_each_frame([&](const Frame& frame, bool is_innermost_frame) {
auto& symbol = frame.symbol;
auto& address = frame.address;
auto& offset = frame.offset;
@@ -142,6 +142,8 @@ void Profile::rebuild_tree()
node = &node->find_or_create_child(symbol, address, offset, event.timestamp);
node->increment_event_count();
+ if (is_innermost_frame)
+ node->increment_self_count();
return IterationDecision::Continue;
});
}
diff --git a/DevTools/ProfileViewer/Profile.h b/DevTools/ProfileViewer/Profile.h
index 379d08828f..8d7933c5e0 100644
--- a/DevTools/ProfileViewer/Profile.h
+++ b/DevTools/ProfileViewer/Profile.h
@@ -48,6 +48,7 @@ public:
u64 timestamp() const { return m_timestamp; }
u32 event_count() const { return m_event_count; }
+ u32 self_count() const { return m_self_count; }
int child_count() const { return m_children.size(); }
const Vector<NonnullRefPtr<ProfileNode>>& children() const { return m_children; }
@@ -78,6 +79,7 @@ public:
const ProfileNode* parent() const { return m_parent; }
void increment_event_count() { ++m_event_count; }
+ void increment_self_count() { ++m_self_count; }
void sort_children();
@@ -95,6 +97,7 @@ private:
u32 m_address { 0 };
u32 m_offset { 0 };
u32 m_event_count { 0 };
+ u32 m_self_count { 0 };
u64 m_timestamp { 0 };
Vector<NonnullRefPtr<ProfileNode>> m_children;
};
diff --git a/DevTools/ProfileViewer/ProfileModel.cpp b/DevTools/ProfileViewer/ProfileModel.cpp
index 0e4214be4f..c9f78a23b8 100644
--- a/DevTools/ProfileViewer/ProfileModel.cpp
+++ b/DevTools/ProfileViewer/ProfileModel.cpp
@@ -98,6 +98,8 @@ String ProfileModel::column_name(int column) const
switch (column) {
case Column::SampleCount:
return "# Samples";
+ case Column::SelfCount:
+ return "# Self";
case Column::StackFrame:
return "Stack Frame";
default:
@@ -108,7 +110,7 @@ String ProfileModel::column_name(int column) const
GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const
{
- if (column == Column::SampleCount)
+ if (column == Column::SampleCount || column == Column::SelfCount)
return ColumnMetadata { 0, Gfx::TextAlignment::CenterRight };
return {};
}
@@ -127,6 +129,8 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const
if (role == Role::Display) {
if (index.column() == Column::SampleCount)
return node->event_count();
+ if (index.column() == Column::SelfCount)
+ return node->self_count();
if (index.column() == Column::StackFrame)
return node->symbol();
return {};
diff --git a/DevTools/ProfileViewer/ProfileModel.h b/DevTools/ProfileViewer/ProfileModel.h
index 7898ee9279..ee72911c32 100644
--- a/DevTools/ProfileViewer/ProfileModel.h
+++ b/DevTools/ProfileViewer/ProfileModel.h
@@ -39,6 +39,7 @@ public:
enum Column {
SampleCount,
+ SelfCount,
StackFrame,
__Count
};