mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 16:55:08 +00:00
ProfileViewer: Precompute the timestamp and "in kernel?" per sample
Instead of fetching these from JSON in every paint event, we now have a separate "SampleData" vector that can be iterated. This optimization was made possible by profiling ProfileViewer and then analyzing the profile with ProfileViewer! :^)
This commit is contained in:
parent
3fd2304dad
commit
4d6968f95d
3 changed files with 20 additions and 4 deletions
|
@ -28,16 +28,16 @@ void ProfileTimelineWidget::paint_event(GPaintEvent& event)
|
|||
|
||||
float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms();
|
||||
|
||||
m_profile.for_each_sample([&](const JsonObject& sample) {
|
||||
u64 t = sample.get("timestamp").to_number<u64>() - m_profile.first_timestamp();
|
||||
for (auto& sample : m_profile.sample_data()) {
|
||||
u64 t = sample.timestamp;
|
||||
int x = (int)((float)t * column_width);
|
||||
int cw = max(1, (int)column_width);
|
||||
|
||||
bool in_kernel = sample.get("frames").as_array().at(1).as_object().get("address").to_number<u32>() < (8 * MB);
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
u64 normalized_start_time = min(m_select_start_time, m_select_end_time);
|
||||
u64 normalized_end_time = max(m_select_start_time, m_select_end_time);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue