From 5e203bc024a3d8a34921ae237ae595002889bf12 Mon Sep 17 00:00:00 2001 From: monsta Date: Tue, 1 Dec 2015 17:50:17 +0300 Subject: process properties: use proper format for "CPU time" property it should be the same as in "CPU time" column of process table now adapted from https://git.gnome.org/browse/gnome-system-monitor/commit/?id=3c1f17877f95fcac7f5d437739305e245af7ba8b --- src/procproperties.cpp | 20 +------------------- src/util.cpp | 4 ++-- src/util.h | 2 ++ 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/procproperties.cpp b/src/procproperties.cpp index bc4993c..2e6cda9 100644 --- a/src/procproperties.cpp +++ b/src/procproperties.cpp @@ -24,12 +24,6 @@ #include #include #include -#if defined (__linux__) -#include -#elif defined (__NetBSD__) || defined (__OpenBSD__) -#include -#include -#endif #include "procman.h" #include "procproperties.h" @@ -115,18 +109,6 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info) get_process_memory_info(info); -#if defined (__NetBSD__) || defined (__OpenBSD__) - struct clockinfo cinf; - size_t size = sizeof (cinf); - int HZ; - int mib[] = { CTL_KERN, KERN_CLOCKRATE }; - - if (sysctl (mib, G_N_ELEMENTS (mib), &cinf, &size, NULL, 0) == -1) - HZ = 100; - else - HZ = cinf.hz; -#endif - proc_arg proc_props[] = { { N_("Process Name"), g_strdup_printf("%s", info->name)}, { N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)}, @@ -138,7 +120,7 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info) { N_("Shared Memory"), format_memsize(info->memshared)}, { N_("X Server Memory"), format_memsize(info->memxserver)}, { N_("CPU"), g_strdup_printf("%d%%", info->pcpu)}, - { N_("CPU Time"), g_strdup_printf(ngettext("%lld second", "%lld seconds", info->cpu_time/HZ), (unsigned long long)info->cpu_time/HZ) }, + { N_("CPU Time"), procman::format_duration_for_display(100 * info->cpu_time / ProcData::get_instance()->frequency) }, { N_("Started"), procman_format_date_for_display(info->start_time) }, { N_("Nice"), g_strdup_printf("%d", info->nice)}, { N_("Priority"), g_strdup_printf("%s", procman::get_nice_level(info->nice)) }, diff --git a/src/util.cpp b/src/util.cpp index 3573f00..0690d48 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -85,8 +85,8 @@ static inline unsigned divide(unsigned *q, unsigned *r, unsigned d) * @param d: duration in centiseconds * @type d: unsigned */ -static char * -format_duration_for_display(unsigned centiseconds) +gchar * +procman::format_duration_for_display(unsigned centiseconds) { unsigned weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0; diff --git a/src/util.h b/src/util.h index aae8482..3d6ef47 100644 --- a/src/util.h +++ b/src/util.h @@ -85,6 +85,8 @@ inline void unref_map_values(Map &map) namespace procman { + gchar* format_duration_for_display(unsigned centiseconds); + void size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data); -- cgit v1.2.1