1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 10:35:07 +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:
Andreas Kling 2019-12-14 19:25:33 +01:00
parent 3fd2304dad
commit 4d6968f95d
3 changed files with 20 additions and 4 deletions

View file

@ -12,6 +12,13 @@ Profile::Profile(const JsonArray& json)
m_model = ProfileModel::create(*this);
rebuild_tree();
m_sample_data.ensure_capacity(m_json.size());
m_json.for_each([&](const JsonValue& sample) {
u64 timestamp = sample.as_object().get("timestamp").to_number<u64>() - m_first_timestamp;
bool in_kernel = sample.as_object().get("frames").as_array().at(1).as_object().get("address").to_number<u32>() < (8 * MB);
m_sample_data.append({ timestamp, in_kernel });
});
}
Profile::~Profile()