summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorMaksym Kryzhanovskyy2010-11-06 01:56:19 +0100
committerDenys Vlasenko2010-11-06 01:56:19 +0100
commit0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5 (patch)
tree099f097653d6ddc9fc273d165d43afe658f167cc /procps
parent9135fd26c485f57a76a94775a66ac4ccf5188990 (diff)
downloadbusybox-0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5.zip
busybox-0ebafcc5b14b8c22a4a10f13328b996f8d85c2a5.tar.gz
powertop: code shrink
function old new delta process_timer_stats 490 449 -41 Signed-off-by: Maksym Kryzhanovskyy <xmaks@email.cz> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'procps')
-rw-r--r--procps/powertop.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/procps/powertop.c b/procps/powertop.c
index da7f052..2f977a0 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -399,6 +399,7 @@ static NOINLINE int process_timer_stats(void)
buf[0] = '\0';
totalticks = 0;
+ n = 0;
fp = NULL;
if (!G.cant_enable_timer_stats)
fp = fopen_for_read("/proc/timer_stats");
@@ -418,14 +419,24 @@ static NOINLINE int process_timer_stats(void)
const char *count, *process, *func;
char *p;
int idx;
+ unsigned cnt;
count = skip_whitespace(buf);
p = strchr(count, ',');
if (!p)
continue;
*p++ = '\0';
- if (strcmp(skip_non_whitespace(count), " total events") == 0)
+ cnt = bb_strtou(count, NULL, 10);
+ if (strcmp(skip_non_whitespace(count), " total events") == 0) {
+#if ENABLE_FEATURE_POWERTOP_PROCIRQ
+ n = cnt / G.total_cpus;
+ if (n > 0 && n < G.interrupt_0) {
+ sprintf(line, " <interrupt> : %s", "extra timer interrupt");
+ save_line(line, G.interrupt_0 - n);
+ }
+#endif
break;
+ }
if (strchr(count, 'D'))
continue; /* deferred */
p = skip_whitespace(p); /* points to pid now */
@@ -471,21 +482,11 @@ static NOINLINE int process_timer_stats(void)
sprintf(line, "%15.15s : %s", process, func);
//else
// sprintf(line, "%s", process);
- save_line(line, bb_strtoull(count, NULL, 10));
+ save_line(line, cnt);
}
fclose(fp);
}
- n = 0;
-#if ENABLE_FEATURE_POWERTOP_PROCIRQ
- if (strstr(buf, " total events")) {
- n = bb_strtoull(buf, NULL, 10) / G.total_cpus;
- if (n > 0 && n < G.interrupt_0) {
- sprintf(line, " <interrupt> : %s", "extra timer interrupt");
- save_line(line, G.interrupt_0 - n);
- }
- }
-#endif
return n;
}