1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

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
This commit is contained in:
Idan Horowitz 2021-10-24 20:50:54 +03:00 committed by Andreas Kling
parent 3e9191936b
commit db68a52e23

View file

@ -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++) {