aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-26 13:03:31 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-26 13:03:31 +0200
commita43e969574fca5ba17bb866c2aa249fe16ac0530 (patch)
tree6ec0b274df8e6ee762b168089d9744ad15efe4b1
parentd8b687f99257772f62edd7c4641427280841e1c5 (diff)
downloadbusybox-w32-a43e969574fca5ba17bb866c2aa249fe16ac0530.tar.gz
busybox-w32-a43e969574fca5ba17bb866c2aa249fe16ac0530.tar.bz2
busybox-w32-a43e969574fca5ba17bb866c2aa249fe16ac0530.zip
powertop: simplified C-state display code
function old new delta .rodata 145530 145514 -16 powertop_main 1510 1403 -107 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--procps/powertop.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/procps/powertop.c b/procps/powertop.c
index 3d98b9bda..8b03a4d12 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -82,7 +82,6 @@ struct globals {
82 ullong last_usage[MAX_CSTATE_COUNT]; 82 ullong last_usage[MAX_CSTATE_COUNT];
83 ullong start_duration[MAX_CSTATE_COUNT]; 83 ullong start_duration[MAX_CSTATE_COUNT];
84 ullong last_duration[MAX_CSTATE_COUNT]; 84 ullong last_duration[MAX_CSTATE_COUNT];
85 char cstate_names[MAX_CSTATE_COUNT][16];
86#if ENABLE_FEATURE_USE_TERMIOS 85#if ENABLE_FEATURE_USE_TERMIOS
87 struct termios init_settings; 86 struct termios init_settings;
88#endif 87#endif
@@ -806,22 +805,19 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
806 805
807 if (totalevents == 0 && G.maxcstate <= 1) { 806 if (totalevents == 0 && G.maxcstate <= 1) {
808 /* This should not happen */ 807 /* This should not happen */
809 sprintf(cstate_lines[5], "< Detailed C-state information is not " 808 strcpy(cstate_lines[0], "C-state information is not available\n");
810 "available.>\n");
811 } else { 809 } else {
812 double percentage; 810 double percentage;
813 double newticks; 811 unsigned newticks;
814 812
815 newticks = G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000 - totalticks; 813 newticks = G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000 - totalticks;
816
817 /* Handle rounding errors: do not display negative values */ 814 /* Handle rounding errors: do not display negative values */
818 if (newticks < 0) 815 if ((int)newticks < 0)
819 newticks = 0; 816 newticks = 0;
820 817
821 sprintf(cstate_lines[0], "Cn\t\t Avg residency\n"); 818 sprintf(cstate_lines[0], "Cn\t\t Avg residency\n");
822 percentage = newticks * 100.0 / (G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000); 819 percentage = newticks * 100.0 / (G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000);
823 sprintf(cstate_lines[1], "C0 (cpu running) (%4.1f%%)\n", 820 sprintf(cstate_lines[1], "C0 (cpu running) (%4.1f%%)\n", percentage);
824 percentage);
825 821
826 /* Compute values for individual C-states */ 822 /* Compute values for individual C-states */
827 for (i = 0; i < MAX_CSTATE_COUNT; i++) { 823 for (i = 0; i < MAX_CSTATE_COUNT; i++) {
@@ -831,11 +827,8 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
831 / (cur_usage[i] - G.last_usage[i] + 0.1) / FREQ_ACPI; 827 / (cur_usage[i] - G.last_usage[i] + 0.1) / FREQ_ACPI;
832 percentage = (cur_duration[i] - G.last_duration[i]) * 100 828 percentage = (cur_duration[i] - G.last_duration[i]) * 100
833 / (G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000); 829 / (G.total_cpus * DEFAULT_SLEEP * FREQ_ACPI_1000);
834 830 sprintf(cstate_lines[i + 2], "C%u\t\t%5.1fms (%4.1f%%)\n",
835 if (!G.cstate_names[i][0]) 831 i + 1, slept, percentage);
836 sprintf(G.cstate_names[i], "C%u", i + 1);
837 sprintf(cstate_lines[i + 2], "%s\t\t%5.1fms (%4.1f%%)\n",
838 G.cstate_names[i], slept, percentage);
839 //if (maxsleep < slept) 832 //if (maxsleep < slept)
840 // maxsleep = slept; 833 // maxsleep = slept;
841 } 834 }
@@ -844,7 +837,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
844 837
845 for (i = 0; i < MAX_CSTATE_COUNT + 2; i++) 838 for (i = 0; i < MAX_CSTATE_COUNT + 2; i++)
846 if (cstate_lines[i][0]) 839 if (cstate_lines[i][0])
847 printf("%s", cstate_lines[i]); 840 fputs(cstate_lines[i], stdout);
848 841
849 i = process_timer_stats(); 842 i = process_timer_stats();
850#if ENABLE_FEATURE_POWERTOP_PROCIRQ 843#if ENABLE_FEATURE_POWERTOP_PROCIRQ