aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2010-12-20 11:14:52 -0800
committerArjan van de Ven <arjan@linux.intel.com>2010-12-20 11:23:51 -0800
commit249350a5c7856aaa4d1236f44814208a3ec48624 (patch)
treee08dbd649a1d8d042eff3698ce0a548d83909714
parent65aebba16d885b56aa42d5ee95788c340a2dd405 (diff)
downloadpowertop-249350a5c7856aaa4d1236f44814208a3ec48624.tar.gz
show wakeup/disk/gpu split in the software detail view;
to keep the code sane spit the summary function out entirely
-rw-r--r--TODO1
-rw-r--r--display.cpp7
-rw-r--r--display.h2
-rw-r--r--main.cpp12
-rw-r--r--process/do_process.cpp103
-rw-r--r--process/process.h4
6 files changed, 110 insertions, 19 deletions
diff --git a/TODO b/TODO
index 31c0e53..42b8e12 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
* html output
- header with powertop version and system info (hw, kernel version, distro)
-
* for unknown USB devices, list VID/PID
diff --git a/display.cpp b/display.cpp
index 3d47327..f23b5d5 100644
--- a/display.cpp
+++ b/display.cpp
@@ -247,3 +247,10 @@ void cursor_enter(void)
}
show_cur_tab();
}
+
+int ncurses_initialized(void)
+{
+ if (display)
+ return 1;
+ return 0;
+}
diff --git a/display.h b/display.h
index c9429ea..fcf8077 100644
--- a/display.h
+++ b/display.h
@@ -33,7 +33,7 @@
using namespace std;
extern void init_display(void);
-
+extern int ncurses_initialized(void);
extern void show_tab(unsigned int tab);
extern void show_next_tab(void);
extern void show_prev_tab(void);
diff --git a/main.cpp b/main.cpp
index 9aff81b..9e20392 100644
--- a/main.cpp
+++ b/main.cpp
@@ -54,6 +54,11 @@ static void do_sleep(int seconds)
time_t target;
int delta;
+ if (!ncurses_initialized()) {
+ sleep(seconds);
+ return;
+ }
+
target = time(NULL) + seconds;
delta = seconds;
do {
@@ -117,13 +122,13 @@ void one_measurement(int seconds)
/* output stats */
process_update_display();
- html_process_update_display(1);
+ html_summary();
w_display_cpu_cstates();
w_display_cpu_pstates();
html_display_cpu_cstates();
html_display_cpu_pstates();
- html_process_update_display(0);
+ html_process_update_display();
tuning_update_display();
end_process_data();
@@ -177,10 +182,11 @@ int main(int argc, char **argv)
if (argc > 1) {
if (strcmp(argv[1], "--html") == 0) {
- init_html_output("powertop.html");
fprintf(stderr, "Measuring for 20 seconds\n");
one_measurement(1);
+ init_html_output("powertop.html");
initialize_tuning();
+ one_measurement(20);
html_show_tunables();
finish_html_output();
diff --git a/process/do_process.cpp b/process/do_process.cpp
index d2965b5..b6a147f 100644
--- a/process/do_process.cpp
+++ b/process/do_process.cpp
@@ -635,7 +635,7 @@ static const char *process_class(int line)
return "process_even";
}
-void html_process_update_display(int summary)
+void html_process_update_display(void)
{
unsigned int i, lines = 0;
unsigned int total;
@@ -649,21 +649,16 @@ void html_process_update_display(int summary)
show_power = global_power_valid();
- if (summary)
- fprintf(htmlout, "<h2>Power consumption summary</h2>\n");
- else
- fprintf(htmlout, "<h2>Overview of software power consumers</h2>\n");
+ fprintf(htmlout, "<h2>Overview of software power consumers</h2>\n");
- fprintf(htmlout, "<table>\n");
+ fprintf(htmlout, "<table width=100%%>\n");
if (show_power)
- fprintf(htmlout, "<tr><th width=10%%>Power est.</th><th width=10%%>Usage/s</th><th width=10%%>Events/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
+ fprintf(htmlout, "<tr><th width=10%%>Power est.</th><th width=10%%>Usage/s</th><th width=10%%>Wakeups/s</th><th width=10%%>GPU ops/s</th><th width=10%%>Disk IO/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
else
- fprintf(htmlout, "<tr><th width=10%%>Usage/s</th><th width=10%%>Events/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
+ fprintf(htmlout, "<tr><th width=10%%>Usage/s</th><th width=10%%>Wakeups/s</th><th width=10%%>GPU ops/s</th><th width=10%%>Disk IO/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
total = all_power.size();
- if (summary && total > 10)
- total = 10;
if (total > 100)
total = 100;
@@ -672,7 +667,9 @@ void html_process_update_display(int summary)
char power[16];
char name[20];
char usage[20];
- char events[20];
+ char wakes[20];
+ char gpus[20];
+ char disks[20];
char descr[128];
format_watts(all_power[i]->Witts(), power, 10);
@@ -696,9 +693,91 @@ void html_process_update_display(int summary)
else
sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
}
+ sprintf(wakes, "%5.1f", all_power[i]->wake_ups / measurement_time);
+ sprintf(gpus, "%5.1f", all_power[i]->gpu_ops / measurement_time);
+ sprintf(disks, "%5.1f (%5.1f)", all_power[i]->hard_disk_hits / measurement_time, all_power[i]->disk_hits / measurement_time);
+ if (!all_power[i]->show_events()) {
+ wakes[0] = 0;
+ gpus[0] = 0;
+ disks[0] = 0;
+ }
+
+ if (all_power[i]->gpu_ops == 0)
+ gpus[0] = 0;
+ if (all_power[i]->wake_ups == 0)
+ wakes[0] = 0;
+ if (all_power[i]->disk_hits == 0)
+ disks[0] = 0;
+
+ if (show_power)
+ fprintf(htmlout, "<tr class=\"%s\"><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td>%s</td><td>%s</td></tr>\n", process_class(lines), power, usage, wakes, gpus, disks, name, pretty_print(all_power[i]->description(), descr, 128));
+ else
+ fprintf(htmlout, "<tr class=\"%s\"><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td>%s</td><td>%s</td></tr>\n", process_class(lines), usage, wakes, gpus, disks, name, pretty_print(all_power[i]->description(), descr, 128));
+ }
+ fprintf(htmlout, "</table>\n");
+}
+
+void html_summary(void)
+{
+ unsigned int i, lines = 0;
+ unsigned int total;
+
+ int show_power;
+
+ if (!htmlout)
+ return;
+
+ sort(all_power.begin(), all_power.end(), power_cpu_sort);
+
+ show_power = global_power_valid();
+
+ fprintf(htmlout, "<h2>Power consumption summary</h2>\n");
+
+ fprintf(htmlout, "<table width=100%%>\n");
+
+ if (show_power)
+ fprintf(htmlout, "<tr><th width=10%%>Power est.</th><th width=10%%>Usage/s</th><th width=10%%>Events/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
+ else
+ fprintf(htmlout, "<tr><th width=10%%>Usage/s</th><th width=10%%>Events/s</th><th width=10%% class=\"process\">Category</th><th class=\"process\">Description</th></tr>\n");
+
+ total = all_power.size();
+ if (total > 10)
+ total = 10;
+
+ for (i = 0; i < all_power.size(); i++) {
+ char power[16];
+ char name[20];
+ char usage[20];
+ char events[20];
+ char descr[128];
+ format_watts(all_power[i]->Witts(), power, 10);
+
+
+ if (!show_power)
+ strcpy(power, " ");
+ sprintf(name, all_power[i]->type());
+
+ lines++;
+
+ if (lines > total)
+ break;
+
+ if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
+ break;
+
+ usage[0] = 0;
+ if (all_power[i]->usage_units()) {
+ if (all_power[i]->usage() < 1000)
+ sprintf(usage, "%5.1f%s", all_power[i]->usage(), all_power[i]->usage_units());
+ else
+ sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units());
+ }
sprintf(events, "%5.1f", all_power[i]->events());
- if (!all_power[i]->show_events())
+ if (!all_power[i]->show_events()) {
events[0] = 0;
+ }
+
+
if (show_power)
fprintf(htmlout, "<tr class=\"%s\"><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td class=\"process_power\">%s</td><td>%s</td><td>%s</td></tr>\n", process_class(lines), power, usage, events, name, pretty_print(all_power[i]->description(), descr, 128));
else
diff --git a/process/process.h b/process/process.h
index fdee9ae..03f257d 100644
--- a/process/process.h
+++ b/process/process.h
@@ -80,8 +80,8 @@ extern class process * find_create_process(char *comm, int pid);
extern void all_processes_to_all_power(void);
extern void process_update_display(void);
-extern void html_process_update_display(int summary);
-
+extern void html_process_update_display(void);
+extern void html_summary(void);