1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:57:44 +00:00

Profiler: Present read event info in tree structure

This commit adds "Filesystem Events" View to the Profiler. This tab
 will present combined information for recorded Filesystem events.
Currently only accumulated count and duration is presented.
Duration amount currently only shows events that took over 1ms,
which means that in most cases 0 is show.
This commit is contained in:
Jakub Berkop 2022-02-17 22:26:20 +01:00 committed by Andreas Kling
parent bc82b3eaec
commit d084f8d90a
6 changed files with 323 additions and 0 deletions

View file

@ -36,6 +36,7 @@ static void sort_profile_nodes(Vector<NonnullRefPtr<ProfileNode>>& nodes)
Profile::Profile(Vector<Process> processes, Vector<Event> events)
: m_processes(move(processes))
, m_events(move(events))
, m_file_event_nodes(FileEventNode::create(""))
{
for (size_t i = 0; i < m_events.size(); ++i) {
if (m_events[i].data.has<Event::SignpostData>())
@ -48,6 +49,7 @@ Profile::Profile(Vector<Process> processes, Vector<Event> events)
m_model = ProfileModel::create(*this);
m_samples_model = SamplesModel::create(*this);
m_signposts_model = SignpostsModel::create(*this);
m_file_event_model = FileEventModel::create(*this);
rebuild_tree();
}
@ -101,6 +103,7 @@ void Profile::rebuild_tree()
m_filtered_event_indices.clear();
m_filtered_signpost_indices.clear();
m_file_event_nodes->children().clear();
for (size_t event_index = 0; event_index < m_events.size(); ++event_index) {
auto& event = m_events.at(event_index);
@ -205,6 +208,21 @@ void Profile::rebuild_tree()
}
}
}
if (event.data.has<Event::ReadData>()) {
auto const& read_event = event.data.get<Event::ReadData>();
auto& event_node = m_file_event_nodes->find_or_create_node(read_event.path);
event_node.for_each_parent_node([&](FileEventNode& node) {
node.increment_count();
// Fixme: Currently events record 'timestamp' and 'start_timestamp' in ms resolution,
// which results in most durations equal to zero. Increasing the resolution should
// make the information more accurate.
auto const duration = event.timestamp - read_event.start_timestamp;
node.add_to_duration(duration);
});
}
}
sort_profile_nodes(roots);
@ -581,6 +599,11 @@ GUI::Model* Profile::source_model()
return m_source_model;
}
GUI::Model* Profile::file_event_model()
{
return m_file_event_model;
}
ProfileNode::ProfileNode(Process const& process)
: m_root(true)
, m_process(process)