summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-02 20:02:45 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-02 23:05:04 +0100
commit8eaac171d781af70c2606ec98d794fd7932009da (patch)
tree30893dec41e708deb18a2014b709f5b20e36a1d0
parent251b7f3776d11eea662cc68fd51b4c911c548d00 (diff)
downloadserenity-8eaac171d781af70c2606ec98d794fd7932009da.zip
ProfileViewer: Rename Profile::Sample => Profile::Event
-rw-r--r--DevTools/ProfileViewer/Profile.cpp66
-rw-r--r--DevTools/ProfileViewer/Profile.h12
-rw-r--r--DevTools/ProfileViewer/ProfileModel.cpp2
-rw-r--r--DevTools/ProfileViewer/ProfileTimelineWidget.cpp8
4 files changed, 44 insertions, 44 deletions
diff --git a/DevTools/ProfileViewer/Profile.cpp b/DevTools/ProfileViewer/Profile.cpp
index 1082c2b535..8abf030a1f 100644
--- a/DevTools/ProfileViewer/Profile.cpp
+++ b/DevTools/ProfileViewer/Profile.cpp
@@ -36,7 +36,7 @@
static void sort_profile_nodes(Vector<NonnullRefPtr<ProfileNode>>& nodes)
{
quick_sort(nodes.begin(), nodes.end(), [](auto& a, auto& b) {
- return a->sample_count() >= b->sample_count();
+ return a->event_count() >= b->event_count();
});
for (auto& child : nodes)
@@ -51,30 +51,30 @@ Profile::Profile(const JsonArray& json)
m_model = ProfileModel::create(*this);
- m_samples.ensure_capacity(m_json.size());
- for (auto& sample_value : m_json.values()) {
+ m_events.ensure_capacity(m_json.size());
+ for (auto& event_value : m_json.values()) {
- auto& sample_object = sample_value.as_object();
+ auto& event_object = event_value.as_object();
- Sample sample;
- sample.timestamp = sample_object.get("timestamp").to_number<u64>();
- sample.type = sample_object.get("type").to_string();
+ Event event;
+ event.timestamp = event_object.get("timestamp").to_number<u64>();
+ event.type = event_object.get("type").to_string();
- if (sample.type == "malloc") {
- sample.ptr = sample_object.get("ptr").to_number<u32>();
- sample.size = sample_object.get("size").to_number<u32>();
- } else if (sample.type == "free") {
- sample.ptr = sample_object.get("ptr").to_number<u32>();
+ if (event.type == "malloc") {
+ event.ptr = event_object.get("ptr").to_number<u32>();
+ event.size = event_object.get("size").to_number<u32>();
+ } else if (event.type == "free") {
+ event.ptr = event_object.get("ptr").to_number<u32>();
}
- auto frames_value = sample_object.get("frames");
+ auto frames_value = event_object.get("frames");
auto& frames_array = frames_value.as_array();
if (frames_array.size() < 2)
continue;
u32 innermost_frame_address = frames_array.at(1).as_object().get("address").to_number<u32>();
- sample.in_kernel = innermost_frame_address >= 0xc0000000;
+ event.in_kernel = innermost_frame_address >= 0xc0000000;
for (int i = frames_array.size() - 1; i >= 1; --i) {
auto& frame_value = frames_array.at(i);
@@ -83,12 +83,12 @@ Profile::Profile(const JsonArray& json)
frame.symbol = frame_object.get("symbol").as_string_or({});
frame.address = frame_object.get("address").as_u32();
frame.offset = frame_object.get("offset").as_u32();
- sample.frames.append(move(frame));
+ event.frames.append(move(frame));
};
m_deepest_stack_depth = max((u32)frames_array.size(), m_deepest_stack_depth);
- m_samples.append(move(sample));
+ m_events.append(move(event));
}
rebuild_tree();
@@ -121,30 +121,30 @@ void Profile::rebuild_tree()
HashTable<uintptr_t> live_allocations;
- for (auto& sample : m_samples) {
+ for (auto& event : m_events) {
if (has_timestamp_filter_range()) {
- auto timestamp = sample.timestamp;
+ auto timestamp = event.timestamp;
if (timestamp < m_timestamp_filter_range_start || timestamp > m_timestamp_filter_range_end)
continue;
}
- if (sample.type == "malloc")
- live_allocations.set(sample.ptr);
- else if (sample.type == "free")
- live_allocations.remove(sample.ptr);
+ if (event.type == "malloc")
+ live_allocations.set(event.ptr);
+ else if (event.type == "free")
+ live_allocations.remove(event.ptr);
}
- for (auto& sample : m_samples) {
+ for (auto& event : m_events) {
if (has_timestamp_filter_range()) {
- auto timestamp = sample.timestamp;
+ auto timestamp = event.timestamp;
if (timestamp < m_timestamp_filter_range_start || timestamp > m_timestamp_filter_range_end)
continue;
}
- if (sample.type == "malloc" && !live_allocations.contains(sample.ptr))
+ if (event.type == "malloc" && !live_allocations.contains(event.ptr))
continue;
- if (sample.type == "free")
+ if (event.type == "free")
continue;
ProfileNode* node = nullptr;
@@ -152,13 +152,13 @@ void Profile::rebuild_tree()
auto for_each_frame = [&]<typename Callback>(Callback callback)
{
if (!m_inverted) {
- for (size_t i = 0; i < sample.frames.size(); ++i) {
- if (callback(sample.frames.at(i)) == IterationDecision::Break)
+ for (size_t i = 0; i < event.frames.size(); ++i) {
+ if (callback(event.frames.at(i)) == IterationDecision::Break)
break;
}
} else {
- for (ssize_t i = sample.frames.size() - 1; i >= 0; --i) {
- if (callback(sample.frames.at(i)) == IterationDecision::Break)
+ for (ssize_t i = event.frames.size() - 1; i >= 0; --i) {
+ if (callback(event.frames.at(i)) == IterationDecision::Break)
break;
}
}
@@ -173,11 +173,11 @@ void Profile::rebuild_tree()
return IterationDecision::Break;
if (!node)
- node = &find_or_create_root(symbol, address, offset, sample.timestamp);
+ node = &find_or_create_root(symbol, address, offset, event.timestamp);
else
- node = &node->find_or_create_child(symbol, address, offset, sample.timestamp);
+ node = &node->find_or_create_child(symbol, address, offset, event.timestamp);
- node->increment_sample_count();
+ node->increment_event_count();
return IterationDecision::Continue;
});
}
diff --git a/DevTools/ProfileViewer/Profile.h b/DevTools/ProfileViewer/Profile.h
index d828d70d40..85a13264a3 100644
--- a/DevTools/ProfileViewer/Profile.h
+++ b/DevTools/ProfileViewer/Profile.h
@@ -47,7 +47,7 @@ public:
u32 offset() const { return m_offset; }
u64 timestamp() const { return m_timestamp; }
- u32 sample_count() const { return m_sample_count; }
+ u32 event_count() const { return m_event_count; }
int child_count() const { return m_children.size(); }
const Vector<NonnullRefPtr<ProfileNode>>& children() const { return m_children; }
@@ -77,7 +77,7 @@ public:
ProfileNode* parent() { return m_parent; }
const ProfileNode* parent() const { return m_parent; }
- void increment_sample_count() { ++m_sample_count; }
+ void increment_event_count() { ++m_event_count; }
void sort_children();
@@ -94,7 +94,7 @@ private:
String m_symbol;
u32 m_address { 0 };
u32 m_offset { 0 };
- u32 m_sample_count { 0 };
+ u32 m_event_count { 0 };
u64 m_timestamp { 0 };
Vector<NonnullRefPtr<ProfileNode>> m_children;
};
@@ -114,7 +114,7 @@ public:
u32 offset { 0 };
};
- struct Sample {
+ struct Event {
u64 timestamp { 0 };
String type;
uintptr_t ptr { 0 };
@@ -123,7 +123,7 @@ public:
Vector<Frame> frames;
};
- const Vector<Sample>& samples() const { return m_samples; }
+ const Vector<Event>& events() const { return m_events; }
u64 length_in_ms() const { return m_last_timestamp - m_first_timestamp; }
u64 first_timestamp() const { return m_first_timestamp; }
@@ -148,7 +148,7 @@ private:
u64 m_first_timestamp { 0 };
u64 m_last_timestamp { 0 };
- Vector<Sample> m_samples;
+ Vector<Event> m_events;
bool m_has_timestamp_filter_range { false };
u64 m_timestamp_filter_range_start { 0 };
diff --git a/DevTools/ProfileViewer/ProfileModel.cpp b/DevTools/ProfileViewer/ProfileModel.cpp
index 70010e5460..0e4214be4f 100644
--- a/DevTools/ProfileViewer/ProfileModel.cpp
+++ b/DevTools/ProfileViewer/ProfileModel.cpp
@@ -126,7 +126,7 @@ GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const
}
if (role == Role::Display) {
if (index.column() == Column::SampleCount)
- return node->sample_count();
+ return node->event_count();
if (index.column() == Column::StackFrame)
return node->symbol();
return {};
diff --git a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp
index c2d9df7dda..025af2c5f9 100644
--- a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp
+++ b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp
@@ -51,14 +51,14 @@ void ProfileTimelineWidget::paint_event(GUI::PaintEvent& event)
float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms();
float frame_height = (float)frame_inner_rect().height() / (float)m_profile.deepest_stack_depth();
- for (auto& sample : m_profile.samples()) {
- u64 t = sample.timestamp - m_profile.first_timestamp();
+ for (auto& event : m_profile.events()) {
+ u64 t = event.timestamp - m_profile.first_timestamp();
int x = (int)((float)t * column_width);
int cw = max(1, (int)column_width);
- int column_height = frame_inner_rect().height() - (int)((float)sample.frames.size() * frame_height);
+ int column_height = frame_inner_rect().height() - (int)((float)event.frames.size() * frame_height);
- bool in_kernel = sample.in_kernel;
+ bool in_kernel = event.in_kernel;
Color color = in_kernel ? Color::from_rgb(0xc25e5a) : Color::from_rgb(0x5a65c2);
for (int i = 0; i < cw; ++i)
painter.draw_line({ x + i, frame_thickness() + column_height }, { x + i, height() - frame_thickness() * 2 }, color);