summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2015-12-01 17:50:17 +0300
committermonsta <[email protected]>2015-12-01 17:50:17 +0300
commit5e203bc024a3d8a34921ae237ae595002889bf12 (patch)
tree9c01ca9d81f2d20ae44895037b6d786295a19d80
parenteeeaff5770c91943baa3c506da3d05b7092c7690 (diff)
downloadmate-system-monitor-5e203bc024a3d8a34921ae237ae595002889bf12.tar.bz2
mate-system-monitor-5e203bc024a3d8a34921ae237ae595002889bf12.tar.xz
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
-rw-r--r--src/procproperties.cpp20
-rw-r--r--src/util.cpp4
-rw-r--r--src/util.h2
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 <glibtop/procmem.h>
#include <glibtop/procmap.h>
#include <glibtop/procstate.h>
-#if defined (__linux__)
-#include <asm/param.h>
-#elif defined (__NetBSD__) || defined (__OpenBSD__)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#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);