From db68a52e23c2571fd0701a4bce70fffe95b5ce81 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 24 Oct 2021 20:50:54 +0300 Subject: [PATCH] Profiler: Use profile length in ms as histogram column count directly Beforehand we were dividing the frame width by the profile length in ms and then dividing the frame width by the result once more, which is equivalent to (but slower) just using the length in ms directly, aside from the case in which the profile is less than 1 ms long, in which case this would trigger undefined behaviour due to the division by zero --- Userland/DevTools/Profiler/TimelineTrack.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Userland/DevTools/Profiler/TimelineTrack.cpp b/Userland/DevTools/Profiler/TimelineTrack.cpp index def00478c9..5e04016a0a 100644 --- a/Userland/DevTools/Profiler/TimelineTrack.cpp +++ b/Userland/DevTools/Profiler/TimelineTrack.cpp @@ -62,11 +62,9 @@ void TimelineTrack::paint_event(GUI::PaintEvent& event) return min(end_of_trace, max(timestamp, start_of_trace)); }; + recompute_histograms_if_needed({ start_of_trace, end_of_trace, (size_t)m_profile.length_in_ms() }); + float column_width = this->column_width(); - size_t columns = frame_inner_rect().width() / column_width; - - recompute_histograms_if_needed({ start_of_trace, end_of_trace, columns }); - float frame_height = (float)frame_inner_rect().height() / (float)m_max_value; for (size_t bucket = 0; bucket < m_kernel_histogram->size(); bucket++) {