1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +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:
Jelle Raaijmakers 2023-02-02 13:00:40 +01:00 committed by Andreas Kling
parent 5d1acdc455
commit f0f9d8f1e0
5 changed files with 43 additions and 21 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 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
@ -7,6 +8,7 @@
#include "DisassemblyModel.h"
#include "Gradient.h"
#include "PercentageFormatting.h"
#include "Profile.h"
#include <LibCore/MappedFile.h>
#include <LibDebug/DebugInfo.h>
@ -185,10 +187,15 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
return colors.value().foreground;
}
if (role == GUI::ModelRole::TextAlignment) {
if (index.column() == Column::SampleCount)
return Gfx::TextAlignment::CenterRight;
}
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::SampleCount) {
if (m_profile.show_percentages())
return ((float)insn.event_count / (float)m_node.event_count()) * 100.0f;
return format_percentage(insn.event_count, m_node.event_count());
return insn.event_count;
}