diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/DevTools/Profiler/ProfileModel.cpp | 14 | ||||
-rw-r--r-- | Userland/DevTools/Profiler/ProfileModel.h | 4 |
2 files changed, 12 insertions, 6 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()) diff --git a/Userland/DevTools/Profiler/ProfileModel.h b/Userland/DevTools/Profiler/ProfileModel.h index 7e78546067..285e95f77f 100644 --- a/Userland/DevTools/Profiler/ProfileModel.h +++ b/Userland/DevTools/Profiler/ProfileModel.h @@ -14,8 +14,8 @@ namespace Profiler { class Profile; // Number of digits after the decimal point for sample percentages. -static constexpr int const number_of_percent_digits = 3; -static constexpr float const percent_digits_rounding_constant = AK::pow(10, number_of_percent_digits); +static constexpr int const number_of_percent_digits = 2; +static constexpr int const percent_digits_rounding = AK::pow(10, number_of_percent_digits); class ProfileModel final : public GUI::Model { public: |