diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-07 02:11:45 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-07 15:35:23 +0200 |
commit | e3ee539fea7e7d2672377c52dd344c45fed44f50 (patch) | |
tree | a94b9077f0a4c96c1dc355c3d10a240103c63c3b /Userland/DevTools/Profiler/main.cpp | |
parent | 7463cbdbdb7668e3f1c09772ac3b62c1c76db483 (diff) | |
download | serenity-e3ee539fea7e7d2672377c52dd344c45fed44f50.zip |
Profiler: Don't iterate all events when filtering timeline view
There is no need to iterate through all events in a profile when
loading the timeline view, as soon as we see one event we can
move on to the next process.
Diffstat (limited to 'Userland/DevTools/Profiler/main.cpp')
-rw-r--r-- | Userland/DevTools/Profiler/main.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 73f543b8b9..414225aa7f 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -98,12 +98,14 @@ int main(int argc, char** argv) auto timeline_view = TimelineView::construct(); for (auto& process : profile->processes()) { - size_t event_count = 0; + bool matching_event_found = false; for (auto& event : profile->events()) { - if (event.pid == process.pid && process.valid_at(event.timestamp)) - ++event_count; + if (event.pid == process.pid && process.valid_at(event.timestamp)) { + matching_event_found = true; + break; + } } - if (!event_count) + if (!matching_event_found) continue; auto& timeline_header = timeline_header_container->add<TimelineHeader>(*profile, process); timeline_header.set_shrink_to_fit(true); |