summaryrefslogtreecommitdiff
path: root/Userland/Applications/SystemMonitor/ProcessModel.cpp
diff options
context:
space:
mode:
authorJulian Offenhäuser <metalvoidzz@gmail.com>2021-09-17 18:38:49 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-17 20:12:48 +0200
commit86571481946ce3a60a354d0072a204ed958651cd (patch)
tree8d6e613ba387987830c07f2d080ee9aed78db584 /Userland/Applications/SystemMonitor/ProcessModel.cpp
parentf552c26c793a4d8dca6af6a6d07f080da0949aa8 (diff)
downloadserenity-86571481946ce3a60a354d0072a204ed958651cd.zip
SystemMonitor: Make process memory statistics more human readable
These are the only instances in SystemMonitor which still show memory statistics in KiB only. They will now adapt to the input size better.
Diffstat (limited to 'Userland/Applications/SystemMonitor/ProcessModel.cpp')
-rw-r--r--Userland/Applications/SystemMonitor/ProcessModel.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp
index 3a7035b163..bf07911b57 100644
--- a/Userland/Applications/SystemMonitor/ProcessModel.cpp
+++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp
@@ -7,6 +7,7 @@
#include "ProcessModel.h"
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
+#include <AK/NumberFormat.h>
#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibGUI/FileIconProvider.h>
@@ -124,11 +125,6 @@ String ProcessModel::column_name(int column) const
}
}
-static String pretty_byte_size(size_t size)
-{
- return String::formatted("{}K", size / 1024);
-}
-
GUI::Variant ProcessModel::data(GUI::ModelIndex const& index, GUI::ModelRole role) const
{
VERIFY(is_within_range(index));
@@ -265,17 +261,17 @@ GUI::Variant ProcessModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
case Column::Priority:
return thread.current_state.priority;
case Column::Virtual:
- return pretty_byte_size(thread.current_state.amount_virtual);
+ return human_readable_size(thread.current_state.amount_virtual);
case Column::Physical:
- return pretty_byte_size(thread.current_state.amount_resident);
+ return human_readable_size(thread.current_state.amount_resident);
case Column::DirtyPrivate:
- return pretty_byte_size(thread.current_state.amount_dirty_private);
+ return human_readable_size(thread.current_state.amount_dirty_private);
case Column::CleanInode:
- return pretty_byte_size(thread.current_state.amount_clean_inode);
+ return human_readable_size(thread.current_state.amount_clean_inode);
case Column::PurgeableVolatile:
- return pretty_byte_size(thread.current_state.amount_purgeable_volatile);
+ return human_readable_size(thread.current_state.amount_purgeable_volatile);
case Column::PurgeableNonvolatile:
- return pretty_byte_size(thread.current_state.amount_purgeable_nonvolatile);
+ return human_readable_size(thread.current_state.amount_purgeable_nonvolatile);
case Column::CPU:
return String::formatted("{:.2}", thread.current_state.cpu_percent);
case Column::Processor: