[Powertop] [PATCH 23/29] report: report tuning with new desig html csv

Alexandra Yates <alexandra.yates at linux.intel.com>
Newsgroups dev.linux.lists.powertop
Message-ID <1383168080-18233-24-git-send-email-alexandra.yates@linux.intel.com>
Changes tunning reporting calls to use the new design on and csv
reports.

Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/report/report-data-html.cpp |    9 +++
 src/report/report-data-html.h   |    2 +
 src/tuning/tuning.cpp           |  125 +++++++++++++++++++++++----------------
 3 files changed, 86 insertions(+), 50 deletions(-)

diff --git a/src/report/report-data-html.cpp b/src/report/report-data-html.cpp
index f0d536d..72d2e52 100644
--- a/src/report/report-data-html.cpp
+++ b/src/report/report-data-html.cpp
@@ -82,6 +82,15 @@ void init_nowarp_table_attr(struct table_attributes *table_css, int rows, int co
 	table_css->cols=cols;
 }
 
+void init_tune_table_attr(struct table_attributes *table_css, int rows, int cols){
+	table_css->table_class="emphasis2";
+	table_css->tr_class="tune";
+	table_css->th_class="emph_title";
+	table_css->td_class="";
+	table_css->pos_table_title=T;
+	table_css->rows=rows;
+	table_css->cols=cols;
+}
 
 /* Other Helper Functions */
 string
diff --git a/src/report/report-data-html.h b/src/report/report-data-html.h
index d2d782b..7e517eb 100644
--- a/src/report/report-data-html.h
+++ b/src/report/report-data-html.h
@@ -56,6 +56,8 @@ init_cpu_table_attr(struct table_attributes *table_css, int title_mod,
 void
 init_nowarp_table_attr(struct table_attributes *table_css, int rows, int cols);
 
+void
+init_tune_table_attr(struct table_attributes *table_css, int rows, int cols);
 
 /* Other helper functions */
 string
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index 3d13cc3..e251f56 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -41,6 +41,7 @@
 #include "../display.h"
 #include "../report/report.h"
 #include "../report/report-maker.h"
+#include "../report/report-data-html.h"
 #include "../lib.h"
 
 static void sort_tunables(void);
@@ -197,72 +198,96 @@ void tuning_window::expose(void)
 void report_show_tunables(void)
 {
 	unsigned int i;
-	bool is_header;
 	/* three tables; bad, unfixable, good */
-
 	sort_tunables();
-	report.begin_section(SECTION_TUNING);
+	string srt_tmp;
+	int idx, rows, cols;
 
-	for (is_header = true, i = 0; i < all_tunables.size(); i++) {
-		int gb;
+	/* First Table */
 
-		gb = all_tunables[i]->good_bad();
-		if (gb != TUNE_BAD)
-			continue;
+	 /* div attr css_class and css_id */
+        tag_attr div_attr;
+        init_div(&div_attr, "", "tuning");
 
-		if (is_header) {
-			report.add_header("Software Settings in need of Tuning");
-			report.begin_table(TABLE_WIDE);
-			report.begin_row();
-			report.begin_cell(CELL_TUNABLE_HEADER);
-			report.add("Description");
-			report.begin_cell(CELL_TUNABLE_HEADER);
-			report.add("Script");
-			is_header = false;
-		}
+	/* Set Table attributes, rows, and cols */
+	table_attributes tune_table_css;
+	cols=2;
+	idx = cols;
+	rows= all_tunables.size() + 1;
+	init_tune_table_attr(&tune_table_css, rows, cols);
 
-		report.begin_row(ROW_TUNABLE_BAD);
-		report.begin_cell();
-		report.add(all_tunables[i]->description());
-		report.begin_cell();
-		report.add(all_tunables[i]->toggle_script());
-	}
+	/* Set Title attributes */
+        tag_attr title_attr;
+        init_title_attr(&title_attr);
 
-	for (i = 0, is_header = true; i < all_untunables.size(); i++) {
-		if (is_header) {
-			report.add_header("Untunable Software Issues");
-			report.begin_table(TABLE_WIDE);
-			report.begin_row();
-			report.begin_cell(CELL_TUNABLE_HEADER);
-			report.add("Description");
-			is_header = false;
-		}
+	/* Set array of data in row Major order */
+	string tunable_data[cols * rows];
+
+	tunable_data[0]="Description";
+	tunable_data[1]="Script";
 
-		report.begin_row(ROW_TUNABLE_BAD);
-		report.begin_cell();
-		report.add(all_untunables[i]->description());
-	}
 
-	for (i = 0, is_header = true; i < all_tunables.size(); i++) {
+	for (i = 0; i < all_tunables.size(); i++) {
 		int gb;
+		gb = all_tunables[i]->good_bad();
+		if (gb != TUNE_BAD)
+			continue;
+		tunable_data[idx]=string(all_tunables[i]->description());
+		idx+=1;
+		tunable_data[idx]=string(all_tunables[i]->toggle_script());
+		idx+=1;
+	}
 
+	/* Report Output */
+	report.add_div(&div_attr);
+	report.add_title(&title_attr,"Software Settings in Need of Tuning");
+	report.add_table(tunable_data, &tune_table_css);
+	report.end_div();
+
+	/* Second Table */
+	/* Set Table attributes, rows, and cols */
+	cols=1;
+	rows= all_untunables.size() + 1;
+	init_tune_table_attr(&tune_table_css, rows, cols);
+
+	/* Set array of data in row Major order */
+	string untunable_data[rows];
+	untunable_data[0]="Description";
+
+	for (i = 0; i < all_untunables.size(); i++)
+		untunable_data[i+1]= string(all_untunables[i]->description());
+
+	/* Report Output */
+	report.add_div(&div_attr);
+	report.add_title(&title_attr,"Untunable Software Issues");
+	report.add_table(untunable_data, &tune_table_css);
+	report.end_div();
+
+	/* Third Table */
+	/* Set Table attributes, rows, and cols */
+	cols=1;
+	rows= all_tunables.size() + 1;
+	init_std_table_attr(&tune_table_css, rows, cols);
+
+	/* Set array of data in row Major order */
+	string tuned_data[rows];
+	tuned_data[0]="Description";
+	idx=cols;
+	for (i = 0; i < all_tunables.size(); i++) {
+		int gb;
 		gb = all_tunables[i]->good_bad();
 		if (gb != TUNE_GOOD)
 			continue;
 
-		if (is_header) {
-			report.add_header("Optimal Tuned Software Settings");
-			report.begin_table(TABLE_WIDE);
-			report.begin_row();
-			report.begin_cell(CELL_TUNABLE_HEADER);
-			report.add("Description");
-			is_header = false;
-		}
+		tuned_data[idx]=string(all_tunables[i]->description());
+		idx+=1;
+        }
+	/* Report Output */
+	report.add_div(&div_attr);
+	report.add_title(&title_attr,"Optimal Tuned Software Settings");
+        report.add_table(tuned_data, &tune_table_css);
+        report.end_div();
 
-		report.begin_row(ROW_TUNABLE);
-		report.begin_cell();
-		report.add(all_tunables[i]->description());
-	}
 }
 
 void clear_tuning()
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.