diff --git a/DevTools/ProfileViewer/Profile.cpp b/DevTools/ProfileViewer/Profile.cpp index 9f2faba2f8..11b9b9e567 100644 --- a/DevTools/ProfileViewer/Profile.cpp +++ b/DevTools/ProfileViewer/Profile.cpp @@ -31,6 +31,9 @@ Profile::Profile(const JsonArray& json) frame.offset = frame_object.get("offset").as_u32(); sample.frames.append(move(frame)); }; + + m_deepest_stack_depth = max((u32)frames_array.size(), m_deepest_stack_depth); + m_samples.append(move(sample)); } diff --git a/DevTools/ProfileViewer/Profile.h b/DevTools/ProfileViewer/Profile.h index d1c14678da..6ffb8514e9 100644 --- a/DevTools/ProfileViewer/Profile.h +++ b/DevTools/ProfileViewer/Profile.h @@ -99,6 +99,7 @@ public: u64 length_in_ms() const { return m_last_timestamp - m_first_timestamp; } u64 first_timestamp() const { return m_first_timestamp; } u64 last_timestamp() const { return m_last_timestamp; } + u32 deepest_stack_depth() const { return m_deepest_stack_depth; } void set_timestamp_filter_range(u64 start, u64 end); void clear_timestamp_filter_range(); @@ -120,4 +121,6 @@ private: bool m_has_timestamp_filter_range { false }; u64 m_timestamp_filter_range_start { 0 }; u64 m_timestamp_filter_range_end { 0 }; + + u32 m_deepest_stack_depth { 0 }; }; diff --git a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp index d520d8696a..ecac800cc8 100644 --- a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp +++ b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp @@ -27,16 +27,19 @@ void ProfileTimelineWidget::paint_event(GPaintEvent& event) painter.add_clip_rect(event.rect()); float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms(); + float frame_height = (float)frame_inner_rect().height() / (float)m_profile.deepest_stack_depth(); for (auto& sample : m_profile.samples()) { u64 t = sample.timestamp - m_profile.first_timestamp(); int x = (int)((float)t * column_width); int cw = max(1, (int)column_width); + int column_height = frame_inner_rect().height() - (int)((float)sample.frames.size() * frame_height); + bool in_kernel = sample.in_kernel; Color color = in_kernel ? Color::from_rgb(0xc25e5a) : Color::from_rgb(0x5a65c2); for (int i = 0; i < cw; ++i) - painter.draw_line({ x + i, frame_thickness() }, { x + i, height() - frame_thickness() * 2 }, color); + painter.draw_line({ x + i, frame_thickness() + column_height }, { x + i, height() - frame_thickness() * 2 }, color); } u64 normalized_start_time = min(m_select_start_time, m_select_end_time);