]> granicus.if.org Git - sysstat/commitdiff
pr_stats.c: Don't use an array for tot_jiffies variable
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 13 Dec 2017 07:47:49 +0000 (08:47 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 13 Dec 2017 07:47:49 +0000 (08:47 +0100)
We don't need 3 variables, only 2 are enough.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
pr_stats.c

index 0e9f66e76c722842debd1afe3ed7710a38ebba1d..bf45b95455c60ff3fab6104f0092023c10294597 100644 (file)
@@ -126,7 +126,7 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                                unsigned long long itv)
 {
        int i;
-       unsigned long long tot_jiffies[3];
+       unsigned long long tot_jiffies_c, tot_jiffies_p;
        unsigned long long deltot_jiffies;
        struct stats_cpu *scc, *scp;
 
@@ -163,17 +163,17 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                 * NB: Don't add cpu_guest/cpu_guest_nice because cpu_user/cpu_nice
                 * already include them.
                 */
-               tot_jiffies[curr] = scc->cpu_user + scc->cpu_nice +
-                                   scc->cpu_sys + scc->cpu_idle +
-                                   scc->cpu_iowait + scc->cpu_hardirq +
-                                   scc->cpu_steal + scc->cpu_softirq;
-               tot_jiffies[prev] = scp->cpu_user + scp->cpu_nice +
-                                   scp->cpu_sys + scp->cpu_idle +
-                                   scp->cpu_iowait + scp->cpu_hardirq +
-                                   scp->cpu_steal + scp->cpu_softirq;
+               tot_jiffies_c = scc->cpu_user + scc->cpu_nice +
+                               scc->cpu_sys + scc->cpu_idle +
+                               scc->cpu_iowait + scc->cpu_hardirq +
+                               scc->cpu_steal + scc->cpu_softirq;
+               tot_jiffies_p = scp->cpu_user + scp->cpu_nice +
+                               scp->cpu_sys + scp->cpu_idle +
+                               scp->cpu_iowait + scp->cpu_hardirq +
+                               scp->cpu_steal + scp->cpu_softirq;
 
                /* Total number of jiffies spent on the interval */
-               deltot_jiffies = get_interval(tot_jiffies[prev], tot_jiffies[curr]);
+               deltot_jiffies = get_interval(tot_jiffies_p, tot_jiffies_c);
 
                printf("%-11s", timestamp[curr]);
 
@@ -190,7 +190,7 @@ __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
                         * (Remember that guest/guest_nice times are already included in
                         * user/nice modes.)
                         */
-                       if (tot_jiffies[curr] == 0) {
+                       if (tot_jiffies_c == 0) {
                                /*
                                 * Set current struct fields (which have been set to zero)
                                 * to values from previous iteration. Hence their values won't