1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:58:10 +00:00

ProcessManager: Add CPU/memory usage graphs in a separate tab.

Finally we get some real use for the new GTabWidget. :^)
This commit is contained in:
Andreas Kling 2019-05-06 03:21:23 +02:00
parent 6df3df62be
commit 25bb7a59ac
10 changed files with 140 additions and 19 deletions

View file

@ -1,4 +1,5 @@
#include "MemoryStatsWidget.h"
#include "GraphWidget.h"
#include <LibGUI/GPainter.h>
#include <LibGUI/GBoxLayout.h>
#include <LibGUI/GLabel.h>
@ -6,8 +7,9 @@
#include <stdio.h>
#include <stdlib.h>
MemoryStatsWidget::MemoryStatsWidget(GWidget* parent)
MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
: GWidget(parent)
, m_graph(graph)
, m_proc_memstat("/proc/memstat")
{
if (!m_proc_memstat.open(CIODevice::OpenMode::ReadOnly))
@ -95,6 +97,9 @@ void MemoryStatsWidget::refresh()
m_user_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(user_pages_alloc), page_count_to_kb(user_pages_available)));
m_supervisor_physical_pages_label->set_text(String::format("%uK/%uK", page_count_to_kb(supervisor_pages_alloc), page_count_to_kb(supervisor_pages_available)));
m_kmalloc_count_label->set_text(String::format("%u/%u (+%u)", kmalloc_call_count, kfree_call_count, kmalloc_call_count - kfree_call_count));
m_graph.set_max(page_count_to_kb(user_pages_available));
m_graph.add_value(page_count_to_kb(user_pages_alloc));
}
}