mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
Profiler: Standardize percentage formatting
This implements the same percentage formatting for the disassembly and flamegraph views as we have for the profile model.
This commit is contained in:
parent
5d1acdc455
commit
f0f9d8f1e0
5 changed files with 43 additions and 21 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue