Enables "CPU Idle" section redesign for html and csv reports preserving
translation macros.
Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
src/cpu/cpu.cpp | 188 +++++++++++++++++++++++++++------------
src/report/report-data-html.cpp | 39 ++++++++
src/report/report-data-html.h | 18 ++++
3 files changed, 187 insertions(+), 58 deletions(-)
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 4a7e197..b8f74a8 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -41,6 +41,7 @@
#include "../display.h"
#include "../report/report.h"
#include "../report/report-maker.h"
+#include "../report/report-data-html.h"
static class abstract_cpu system_level;
@@ -420,122 +421,193 @@ static int get_cstates_num(void)
void report_display_cpu_cstates(void)
{
- char buffer[512], buffer2[512];
+ char buffer[512], buffer2[512], tmp_num[50];
unsigned int package, core, cpu;
- int line, cstates_num;
+ int line, cstates_num, title=0, core_num=0;
class abstract_cpu *_package, * _core, * _cpu;
cstates_num = get_cstates_num();
+ /* div attr css_class and css_id */
+ tag_attr div_attr;
+ init_div(&div_attr, "clear_block", "cpuidle");
+
+ /* Set Table attributes, rows, and cols */
+ table_attributes std_table_css;
+ table_size pkg_tbl_size;
+ table_size core_tbl_size;
+ table_size cpu_tbl_size;
+
+
+ /* Set Title attributes */
+ tag_attr title_attr;
+ init_title_attr(&title_attr);
- report.begin_section(SECTION_CPUIDLE);
- report.add_header("Processor Idle state report");
+ /* Report add section */
+ report.add_div(&div_attr);
+ report.add_title(&title_attr, __("Processor Idle State Report"));
+
+ /* Set array of data in row Major order */
+ int idx1, idx2, idx3;
+ string tmp_str;
for (package = 0; package < system_level.children.size(); package++) {
bool first_core = true;
+ idx1=0;
+ idx2=0;
+ idx3=0;
_package = system_level.children[package];
if (!_package)
continue;
+ /* Tables for PKG, CORE, CPU */
+ pkg_tbl_size.cols=2;
+ pkg_tbl_size.rows= cstates_num+1;
+ string pkg_data[pkg_tbl_size.cols * pkg_tbl_size.rows];
+
+ core_tbl_size.cols=2;
+ core_tbl_size.rows=(cstates_num *_package->children.size())
+ + _package->children.size();
+ string core_data[core_tbl_size.cols * core_tbl_size.rows];
+ int num_cpus=0;
+
+ for (core = 0; core < _package->children.size(); core++) {
+ _core = _package->children[core];
+ if (!_core)
+ continue;
+ for (cpu = 0; cpu < _core->children.size(); cpu++) {
+ if (!_cpu)
+ continue;
+ _cpu = _core->children[cpu];
+ num_cpus+=1;
+ }
+ }
+
+ cpu_tbl_size.cols=((2 * num_cpus)+1) ;
+ cpu_tbl_size.rows= cstates_num * _package->children.size();
+
+ string cpu_data[cpu_tbl_size.cols * cpu_tbl_size.rows];
- report.begin_table(TABLE_WIDE);
for (core = 0; core < _package->children.size(); core++) {
+ cpu_data[idx3]=" ";
+ idx3+=1;
_core = _package->children[core];
+
if (!_core)
continue;
+ /* *** PKG STARTS *** */
for (line = LEVEL_HEADER; line <= cstates_num; line++) {
bool first_cpu = true;
-
if (!_package->has_cstate_level(line))
- continue;
-
- report.begin_row();
+ continue;
buffer[0] = 0;
buffer2[0] = 0;
-
if (line == LEVEL_HEADER) {
if (first_core) {
- report.begin_cell(CELL_FIRST_PACKAGE_HEADER);
- report.addf(__("Package %i"), _package->get_number());
- } else {
- report.begin_cell(CELL_EMPTY_PACKAGE_HEADER);
- report.add_empty_cell();
+ pkg_data[idx1]=__("Package");
+ idx1+=1;
+ sprintf(tmp_num,"%d", _package->get_number());
+ pkg_data[idx1]= string(tmp_num);
+ idx1+=1;
}
} else if (first_core) {
- report.begin_cell(CELL_STATE_NAME);
- report.add(_package->fill_cstate_name(line, buffer));
- report.begin_cell(CELL_PACKAGE_STATE_VALUE);
- report.add(_package->fill_cstate_line(line, buffer2));
- } else {
- report.begin_cell(CELL_EMPTY_PACKAGE_STATE);
- report.add_empty_cell();
+ tmp_str=string(_package->fill_cstate_name(line, buffer));
+ pkg_data[idx1]=(tmp_str=="" ? " " : tmp_str);
+ idx1+=1;
+ tmp_str=string(_package->fill_cstate_line(line, buffer2));
+ pkg_data[idx1]=(tmp_str=="" ? " " : tmp_str);
+ idx1+=1;
}
- report.begin_cell(CELL_SEPARATOR);
- report.add_empty_cell();
-
+ /* *** CORE STARTS *** */
if (!_core->can_collapse()) {
buffer[0] = 0;
buffer2[0] = 0;
if (line == LEVEL_HEADER) {
- report.begin_cell(CELL_CORE_HEADER);
/* Here we need to check for which core type we
- * are using. Do not use the core type for the
- * report.addf as it breaks an important macro use
- * for translation decision making for the reports.
- */
- const char* core_type = _core->get_type();
- if (core_type != NULL) {
+ * are using. Do not use the core type for the
+ * report.addf as it breaks an important macro use
+ * for translation decision making for the reports.
+ * */
+ const char* core_type = _core->get_type();
+ if (core_type != NULL) {
if (strcmp(core_type, "Core") == 0 ) {
- report.addf(__("Core %i"), _core->get_number());
+ core_data[idx2]="";
+ idx2+=1;
+ sprintf(tmp_num, __("Core %d"),_core->get_number());
+ core_data[idx2]=string(tmp_num);
+ idx2+=1;
+ core_num+=1;
} else {
- report.addf(__("GPU %i"), _core->get_number());
- }
+ core_data[idx2]="";
+ idx2+=1;
+ sprintf(tmp_num,__("GPU %d"),_core->get_number());
+ core_data[idx2]=string(tmp_num);
+ idx2+=1;
+ }
}
- } else {
- report.begin_cell(CELL_STATE_NAME);
-
report.add(_core->fill_cstate_name(line, buffer));
- report.begin_cell(CELL_CORE_STATE_VALUE);
- report.add(_core->fill_cstate_line(line, buffer2));
+ } else {
+ tmp_str=string(_core->fill_cstate_name(line, buffer));
+ core_data[idx2]=(tmp_str=="" ? " " : tmp_str);
+ idx2+=1;
+ tmp_str=string(_core->fill_cstate_line(line, buffer2));
+ core_data[idx2]=(tmp_str=="" ? " " : tmp_str);
+ idx2+=1;
}
}
-
- report.begin_cell(CELL_SEPARATOR);
- report.add_empty_cell();
-
+ // *** CPU STARTS ***
for (cpu = 0; cpu < _core->children.size(); cpu++) {
_cpu = _core->children[cpu];
+
if (!_cpu)
continue;
-
- report.set_cpu_number(cpu);
if (line == LEVEL_HEADER) {
- report.begin_cell(CELL_CPU_CSTATE_HEADER);
- report.addf(__("CPU %i"), _cpu->get_number());
+ cpu_data[idx3] = __("CPU");
+ idx3+=1;
+ sprintf(tmp_num,"%d",_cpu->get_number());
+ cpu_data[idx3]=string(tmp_num);
+ idx3+=1;
continue;
}
if (first_cpu) {
- report.begin_cell(CELL_STATE_NAME);
- report.add(_cpu->fill_cstate_name(line, buffer));
+ title+=1;
+ cpu_data[idx3]=(string(_cpu->fill_cstate_name(line, buffer)));
+ idx3+=1;
first_cpu = false;
}
buffer[0] = 0;
- report.begin_cell(CELL_CPU_STATE_VALUE);
- report.add(_cpu->fill_cstate_percentage(line, buffer));
- report.begin_cell(CELL_CPU_STATE_VALUE);
- if (line != LEVEL_C0)
- report.add(_cpu->fill_cstate_time(line, buffer));
- else
- report.add_empty_cell();
+ tmp_str=string(_cpu->fill_cstate_percentage(line, buffer));
+ cpu_data[idx3]=(tmp_str=="" ? " " : tmp_str);
+ idx3+=1;
+
+ if (line != LEVEL_C0){
+ tmp_str=string(_cpu->fill_cstate_time(line, buffer));
+ cpu_data[idx3]=(tmp_str=="" ? " " : tmp_str);
+ idx3+=1;
+ } else {
+ cpu_data[idx3]=" ";
+ idx3+=1;
+ }
}
}
-
first_core = false;
}
+
+ /* Report Output */
+ title=title/core_num;
+ init_pkg_table_attr(&std_table_css, pkg_tbl_size.rows, pkg_tbl_size.cols);
+ report.add_table(pkg_data, &std_table_css);
+ init_core_table_attr(&std_table_css, title+1, core_tbl_size.rows,
+ core_tbl_size.cols);
+ report.add_table(core_data, &std_table_css);
+ init_cpu_table_attr(&std_table_css, title+1, cpu_tbl_size.rows,
+ cpu_tbl_size.cols);
+ report.add_table(cpu_data, &std_table_css);
}
+ report.end_div();
}
void report_display_cpu_pstates(void)
diff --git a/src/report/report-data-html.cpp b/src/report/report-data-html.cpp
index ed0d692..28732c9 100644
--- a/src/report/report-data-html.cpp
+++ b/src/report/report-data-html.cpp
@@ -35,6 +35,45 @@ void init_std_table_attr(struct table_attributes *table_css, int rows,
int cols)
table_css->cols=cols;
}
+void init_pkg_table_attr(struct table_attributes *table_css, int rows, int cols){
+ table_css->table_class="emphasis2 side_by_side_left";
+ table_css->tr_class="";
+ table_css->th_class="title";
+ table_css->td_class="package";
+ table_css->pos_table_title=T;
+ table_css->title_mod=0;
+ table_css->rows=rows;
+ table_css->cols=cols;
+}
+
+void init_core_table_attr(struct table_attributes *table_css, int title_mod,
+ int rows, int cols){
+ table_css->table_class="emphasis2 side_by_side_left";
+ table_css->tr_class="";
+ table_css->th_class="title";
+ table_css->td_class="core";
+ table_css->pos_table_title=TC;
+ table_css->title_mod=title_mod;
+ table_css->rows=rows;
+ table_css->cols=cols;
+}
+
+void init_cpu_table_attr(struct table_attributes *table_css, int title_mod,
+ int rows, int cols){
+ table_css->table_class="emphasis2 side_by_side_left";
+ table_css->tr_class="";
+ table_css->th_class="title";
+ table_css->td_class="cpu";
+ table_css->pos_table_title=TLC;
+ table_css->title_mod=title_mod;
+ table_css->rows=rows;
+ table_css->cols=cols;
+}
+
+
+
+
+
/* Other Helper Functions */
string
double_to_string(double dval)
diff --git a/src/report/report-data-html.h b/src/report/report-data-html.h
index 524cd24..61e75c0 100644
--- a/src/report/report-data-html.h
+++ b/src/report/report-data-html.h
@@ -21,6 +21,12 @@ struct table_attributes {
int cols;
};
+struct table_size {
+ int rows;
+ int cols;
+};
+
+
/* Definition of css atributes for the cases that apply to powertop
* html report
* */
@@ -37,6 +43,18 @@ init_title_attr(struct tag_attr *title_attr);
void
init_std_table_attr(struct table_attributes *table_css, int rows, int cols);
+void
+init_pkg_table_attr(struct table_attributes *table_css, int rows, int cols);
+
+void
+init_core_table_attr(struct table_attributes *table_css, int title_mod,
+ int rows, int cols);
+
+void
+init_cpu_table_attr(struct table_attributes *table_css, int title_mod,
+ int rows, int cols);
+
+
/* Other helper functions */
string
double_to_string(double dval);
--
1.7.9.5