diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2010-10-09 21:48:08 -0700 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2010-10-09 21:48:08 -0700 |
commit | 74688919596ffc5bbae97d05e997b80f5ca0aa4c (patch) | |
tree | 94e72e401bee5994c470416452ba4ce12ed17498 /process | |
parent | 4a70b11e56d8f2a88bbf4ee8a0e38797830c9949 (diff) | |
download | powertop-74688919596ffc5bbae97d05e997b80f5ca0aa4c.tar.gz |
don't divide by 0
Diffstat (limited to 'process')
-rw-r--r-- | process/do_process.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/process/do_process.cpp b/process/do_process.cpp index 45cd1b1..4ea2111 100644 --- a/process/do_process.cpp +++ b/process/do_process.cpp @@ -511,6 +511,7 @@ void process_update_display(void) { unsigned int i; WINDOW *win; + double sum; sort(all_power.begin(), all_power.end(), power_cpu_sort); @@ -523,8 +524,14 @@ void process_update_display(void) wmove(win, 2,0); calculate_params(); - wprintw(win, "Estimated power: %5.1f Measured power: %5.1f\n\n", - all_parameters.guessed_power, global_joules_consumed()); + sum = 0.0; + sum += get_parameter_value("base power"); + for (i = 0; i < all_power.size(); i++) { + sum += all_power[i]->Witts(); + } + + wprintw(win, "Estimated power: %5.1f Measured power: %5.1f Sum: %5.1f\n\n", + all_parameters.guessed_power, global_joules_consumed(), sum); wprintw(win, "Power est. Usage/s Events/s Category Description\n"); @@ -538,6 +545,10 @@ void process_update_display(void) sprintf(name, all_power[i]->type()); while (strlen(name) < 14) strcat(name, " "); + + 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) |