summaryrefslogtreecommitdiff
path: root/Userland/DevTools/Profiler/ProfileModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/DevTools/Profiler/ProfileModel.cpp')
-rw-r--r--Userland/DevTools/Profiler/ProfileModel.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp
index c4a686d18d..3274443b59 100644
--- a/Userland/DevTools/Profiler/ProfileModel.cpp
+++ b/Userland/DevTools/Profiler/ProfileModel.cpp
@@ -1,11 +1,13 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "ProfileModel.h"
+#include "PercentageFormatting.h"
#include "Profile.h"
#include <LibGUI/FileIconProvider.h>
#include <LibSymbolication/Symbolication.h>
@@ -111,25 +113,14 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
return {};
}
if (role == GUI::ModelRole::Display) {
- 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 DeprecatedString::formatted(
- "{}.{:02}",
- percentage_full_precision / percent_digits_rounding,
- percentage_full_precision % percent_digits_rounding);
- };
if (index.column() == Column::SampleCount) {
if (m_profile.show_percentages())
- return round_percentages(node->event_count());
+ return format_percentage(node->event_count(), m_profile.filtered_event_indices().size());
return node->event_count();
}
if (index.column() == Column::SelfCount) {
if (m_profile.show_percentages())
- return round_percentages(node->self_count());
+ return format_percentage(node->self_count(), m_profile.filtered_event_indices().size());
return node->self_count();
}
if (index.column() == Column::ObjectName)