[gnome-system-monitor] Use the same CPU time format in the process properties than in the process list by using format_dura
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Use the same CPU time format in the process properties than in the process list by using format_dura
- Date: Mon, 2 Mar 2015 18:05:29 +0000 (UTC)
commit 3c1f17877f95fcac7f5d437739305e245af7ba8b
Author: Benoit Dejean <bdejean gmail com>
Date: Sat Feb 28 05:24:34 2015 +0100
Use the same CPU time format in the process properties than in the process list by using
format_duration_for_display(). Get rid of useless OS-specific code.
Signed-off-by: Robert Roth <robert roth off gmail com>
src/procproperties.cpp | 25 +------------------------
src/util.cpp | 4 ++--
src/util.h | 2 ++
3 files changed, 5 insertions(+), 26 deletions(-)
---
diff --git a/src/procproperties.cpp b/src/procproperties.cpp
index 5f68d52..eac0fe3 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(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#endif
#include "application.h"
#include "procproperties.h"
@@ -68,23 +62,6 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
get_process_memory_writable (info);
-#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- 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.stathz ? cinf.stathz : cinf.hz);
-#endif
-#ifdef __GNU__
- int HZ;
- HZ = sysconf(_SC_CLK_TCK);
- if (HZ < 0)
- HZ = 100;
-#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)},
@@ -98,7 +75,7 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
{ N_("X Server Memory"), format_memsize(info->memxserver)},
#endif
{ 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 /
GsmApplication::get()->frequency) },
{ N_("Started"), g_strdup_printf("%s", ctime((const time_t*)(&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 6bf2a54..93e080c 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -82,8 +82,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)
+char *
+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 4c6c8bb..0118df4 100644
--- a/src/util.h
+++ b/src/util.h
@@ -45,6 +45,8 @@ inline string make_string(char *c_str)
namespace procman
{
+ char* format_duration_for_display(unsigned centiseconds);
+
void size_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
GtkTreeModel *model, GtkTreeIter *iter,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]