diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-08-31 16:36:33 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-31 16:57:40 +0100 |
commit | a373542f4c2e6290c347e3209adb2e920d91eec0 (patch) | |
tree | 8e9f50f3d7f2168fea639e863a4744a4feb09694 /Userland/DevTools/Profiler/ProfileModel.cpp | |
parent | fcf86b07a58dacd173b449e25f91b43c35d665ce (diff) | |
download | serenity-a373542f4c2e6290c347e3209adb2e920d91eec0.zip |
Profiler: Display correctly rounded percentages as '#.##%'
Diffstat (limited to 'Userland/DevTools/Profiler/ProfileModel.cpp')
-rw-r--r-- | Userland/DevTools/Profiler/ProfileModel.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index 7390410082..e86868202a 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -111,10 +111,16 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol return {}; } if (role == GUI::ModelRole::Display) { - auto round_percentages = [this](auto percentage) { - return roundf(static_cast<float>(percentage) / static_cast<float>(m_profile.filtered_event_indices().size()) - * percent_digits_rounding_constant) - * 100.0f / percent_digits_rounding_constant; + auto round_percentages = [this](auto value) { + auto percentage_full_precision = round_to<int>( + static_cast<float>(value) + * 100.f + / static_cast<float>(m_profile.filtered_event_indices().size()) + * percent_digits_rounding); + return String::formatted( + "{}.{:02}", + percentage_full_precision / percent_digits_rounding, + percentage_full_precision % percent_digits_rounding); }; if (index.column() == Column::SampleCount) { if (m_profile.show_percentages()) |