mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-20 08:22:19 +00:00
ProfileViewer: Scale the sample columns by stack depth
From a nice suggestion by Nagy Tibor. :^)
This commit is contained in:
parent
7a64f55c0f
commit
be0b527cfc
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue