2009-10-31 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 31 Oct 2009 04:06:50 +0000 (04:06 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 31 Oct 2009 04:06:50 +0000 (04:06 -0000)
* mono-perfcounters.c: add the "_Total" instance for CPU counters.
Until now, we only had the per-cpu(core) counters.

2009-10-30 Gonzalo Paniagua Javier <gonzalo@novell.com>

* mono-proclib.c: hz is only multiplied by the number of cpus when
requesting "_Total".

Fixes bug #523520.

svn path=/trunk/mono/; revision=145134

mono/metadata/ChangeLog
mono/metadata/mono-perfcounters.c
mono/utils/ChangeLog
mono/utils/mono-proclib.c

index 15a3a2746740eaf5ee8e8c4f29223069ffc25cd5..8f8bc04c7d444669f2a883b3a18c4d8995e8e9fa 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-31 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-perfcounters.c: add the "_Total" instance for CPU counters.
+       Until now, we only had the per-cpu(core) counters.
+
 2009-10-28  Mark Probst  <mark.probst@gmail.com>
 
        * gc-internal.h, boehm-gc, sgen-gc.c, null-gc: Add
index 517688faa5e6c16da906a9bb660028fa3237ac7a..e45a24a638961a463033b9c3b2509fd37c2b19c5 100644 (file)
@@ -1493,12 +1493,14 @@ get_cpu_instances (void)
        void **buf = NULL;
        int i, count;
        MonoArray *array;
-       count = mono_cpu_count ();
+
+       count = mono_cpu_count () + 1; /* +1 for "_Total" */
        buf = g_new (void*, count);
        for (i = 0; i < count; ++i)
-               buf [i] = GINT_TO_POINTER (i);
+               buf [i] = GINT_TO_POINTER (i - 1); /* -1 => _Total */
        array = get_string_array (buf, count, FALSE);
        g_free (buf);
+       mono_array_setref (array, 0, mono_string_new (mono_domain_get (), "_Total"));
        return array;
 }
 
index 15a7bb23fd79693fc993f43a3ef90d1271871245..07cb1fcf455cc3194174e9428fe8cb93f69604f0 100644 (file)
@@ -1,3 +1,8 @@
+2009-10-30 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * mono-proclib.c: hz is only multiplied by the number of cpus when
+       requesting "_Total".
+
 2009-10-29  Mark Probst  <mark.probst@gmail.com>
 
        * mono-hash.c (mono_g_hash_mark): Don't use SET_NODE_KEY/VALUE here.
index fa5f293814b5ed6168286140e2740f628d9a475e..029c8abf644bc09bf47764d112708019658fd654 100644 (file)
@@ -402,7 +402,8 @@ get_cpu_times (int cpu_id, gint64 *user, gint64 *systemt, gint64 *irq, gint64 *s
        FILE *f = fopen ("/proc/stat", "r");
        if (!f)
                return;
-       hz *= mono_cpu_count ();
+       if (cpu_id < 0)
+               hz *= mono_cpu_count ();
        while ((s = fgets (buf, sizeof (buf), f))) {
                char *data = NULL;
                if (cpu_id < 0 && strncmp (s, "cpu", 3) == 0 && g_ascii_isspace (s [3])) {