mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:47:45 +00:00
Profiler: Let the user select more than one process
This commit is contained in:
parent
325d9445fd
commit
210d2d270d
3 changed files with 47 additions and 21 deletions
|
@ -376,26 +376,39 @@ void Profile::clear_timestamp_filter_range()
|
||||||
m_samples_model->update();
|
m_samples_model->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::set_process_filter(pid_t pid, u64 start_valid, u64 end_valid)
|
void Profile::add_process_filter(pid_t pid, u64 start_valid, u64 end_valid)
|
||||||
{
|
{
|
||||||
if (m_has_process_filter && m_process_filter_pid == pid && m_process_filter_start_valid == start_valid && m_process_filter_end_valid == end_valid)
|
auto filter = ProcessFilter { pid, start_valid, end_valid };
|
||||||
|
if (m_process_filters.contains_slow(filter))
|
||||||
return;
|
return;
|
||||||
m_has_process_filter = true;
|
m_process_filters.append(move(filter));
|
||||||
|
|
||||||
m_process_filter_pid = pid;
|
|
||||||
m_process_filter_start_valid = start_valid;
|
|
||||||
m_process_filter_end_valid = end_valid;
|
|
||||||
|
|
||||||
rebuild_tree();
|
rebuild_tree();
|
||||||
if (m_disassembly_model)
|
if (m_disassembly_model)
|
||||||
m_disassembly_model->update();
|
m_disassembly_model->update();
|
||||||
m_samples_model->update();
|
m_samples_model->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profile::remove_process_filter(pid_t pid, u64 start_valid, u64 end_valid)
|
||||||
|
{
|
||||||
|
auto filter = ProcessFilter { pid, start_valid, end_valid };
|
||||||
|
if (!m_process_filters.contains_slow(filter))
|
||||||
|
return;
|
||||||
|
m_process_filters.remove_first_matching([&filter](ProcessFilter const& other_filter) {
|
||||||
|
return other_filter == filter;
|
||||||
|
});
|
||||||
|
|
||||||
|
rebuild_tree();
|
||||||
|
if (m_disassembly_model)
|
||||||
|
m_disassembly_model->update();
|
||||||
|
m_samples_model->update();
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::clear_process_filter()
|
void Profile::clear_process_filter()
|
||||||
{
|
{
|
||||||
if (!m_has_process_filter)
|
if (m_process_filters.is_empty())
|
||||||
return;
|
return;
|
||||||
m_has_process_filter = false;
|
m_process_filters.clear();
|
||||||
rebuild_tree();
|
rebuild_tree();
|
||||||
if (m_disassembly_model)
|
if (m_disassembly_model)
|
||||||
m_disassembly_model->update();
|
m_disassembly_model->update();
|
||||||
|
@ -407,7 +420,11 @@ bool Profile::process_filter_contains(pid_t pid, u32 timestamp)
|
||||||
if (!has_process_filter())
|
if (!has_process_filter())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return (pid == m_process_filter_pid && timestamp >= m_process_filter_start_valid && timestamp <= m_process_filter_end_valid);
|
for (auto const& process_filter : m_process_filters)
|
||||||
|
if (pid == process_filter.pid && timestamp >= process_filter.start_valid && timestamp <= process_filter.end_valid)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Profile::set_inverted(bool inverted)
|
void Profile::set_inverted(bool inverted)
|
||||||
|
|
|
@ -116,6 +116,17 @@ private:
|
||||||
Bitmap m_seen_events;
|
Bitmap m_seen_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ProcessFilter {
|
||||||
|
pid_t pid { 0 };
|
||||||
|
u64 start_valid { 0 };
|
||||||
|
u64 end_valid { 0 };
|
||||||
|
|
||||||
|
bool operator==(ProcessFilter const& rhs) const
|
||||||
|
{
|
||||||
|
return pid == rhs.pid && start_valid == rhs.start_valid && end_valid == rhs.end_valid;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Profile {
|
class Profile {
|
||||||
public:
|
public:
|
||||||
static Result<NonnullOwnPtr<Profile>, String> load_from_perfcore_file(const StringView& path);
|
static Result<NonnullOwnPtr<Profile>, String> load_from_perfcore_file(const StringView& path);
|
||||||
|
@ -171,9 +182,10 @@ public:
|
||||||
void clear_timestamp_filter_range();
|
void clear_timestamp_filter_range();
|
||||||
bool has_timestamp_filter_range() const { return m_has_timestamp_filter_range; }
|
bool has_timestamp_filter_range() const { return m_has_timestamp_filter_range; }
|
||||||
|
|
||||||
void set_process_filter(pid_t pid, u64 start_valid, u64 end_valid);
|
void add_process_filter(pid_t pid, u64 start_valid, u64 end_valid);
|
||||||
|
void remove_process_filter(pid_t pid, u64 start_valid, u64 end_valid);
|
||||||
void clear_process_filter();
|
void clear_process_filter();
|
||||||
bool has_process_filter() const { return m_has_process_filter; }
|
bool has_process_filter() const { return !m_process_filters.is_empty(); }
|
||||||
bool process_filter_contains(pid_t pid, u32 timestamp);
|
bool process_filter_contains(pid_t pid, u32 timestamp);
|
||||||
|
|
||||||
bool is_inverted() const { return m_inverted; }
|
bool is_inverted() const { return m_inverted; }
|
||||||
|
@ -222,10 +234,7 @@ private:
|
||||||
u64 m_timestamp_filter_range_start { 0 };
|
u64 m_timestamp_filter_range_start { 0 };
|
||||||
u64 m_timestamp_filter_range_end { 0 };
|
u64 m_timestamp_filter_range_end { 0 };
|
||||||
|
|
||||||
bool m_has_process_filter { false };
|
Vector<ProcessFilter> m_process_filters;
|
||||||
pid_t m_process_filter_pid { 0 };
|
|
||||||
u64 m_process_filter_start_valid { 0 };
|
|
||||||
u64 m_process_filter_end_valid { 0 };
|
|
||||||
|
|
||||||
u32 m_deepest_stack_depth { 0 };
|
u32 m_deepest_stack_depth { 0 };
|
||||||
bool m_inverted { false };
|
bool m_inverted { false };
|
||||||
|
|
|
@ -110,11 +110,11 @@ int main(int argc, char** argv)
|
||||||
auto& timeline_header = timeline_header_container->add<TimelineHeader>(*profile, process);
|
auto& timeline_header = timeline_header_container->add<TimelineHeader>(*profile, process);
|
||||||
timeline_header.set_shrink_to_fit(true);
|
timeline_header.set_shrink_to_fit(true);
|
||||||
timeline_header.on_selection_change = [&](bool selected) {
|
timeline_header.on_selection_change = [&](bool selected) {
|
||||||
if (selected) {
|
auto end_valid = process.end_valid == 0 ? profile->last_timestamp() : process.end_valid;
|
||||||
auto end_valid = process.end_valid == 0 ? profile->last_timestamp() : process.end_valid;
|
if (selected)
|
||||||
profile->set_process_filter(process.pid, process.start_valid, end_valid);
|
profile->add_process_filter(process.pid, process.start_valid, end_valid);
|
||||||
} else
|
else
|
||||||
profile->clear_process_filter();
|
profile->remove_process_filter(process.pid, process.start_valid, end_valid);
|
||||||
|
|
||||||
timeline_header_container->for_each_child_widget([](auto& other_timeline_header) {
|
timeline_header_container->for_each_child_widget([](auto& other_timeline_header) {
|
||||||
static_cast<TimelineHeader&>(other_timeline_header).update_selection();
|
static_cast<TimelineHeader&>(other_timeline_header).update_selection();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue