All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH v3 19/31] report: redesign Software Information csv and html
@ 2013-11-18 20:27 Alexandra Yates
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandra Yates @ 2013-11-18 20:27 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 6288 bytes --]

Enabled "Overview of Software Power Consumers" section
for csv and html report redesign, while preserving
translation macros.

Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
 src/process/do_process.cpp      |  113 ++++++++++++++++++++++-----------------
 src/report/report-data-html.cpp |   11 +++-
 src/report/report-data-html.h   |    2 +
 3 files changed, 77 insertions(+), 49 deletions(-)

diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index c676978..6fc7a5b 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -889,42 +889,48 @@ void report_process_update_display(void)
 {
 	unsigned int i;
 	unsigned int total;
+	int show_power, cols, rows, idx;
 
-	int show_power;
-
-	sort(all_power.begin(), all_power.end(), power_cpu_sort);
-
-	show_power = global_power_valid();
+	/* div attr css_class and css_id */
+	tag_attr div_attr;
+	init_div(&div_attr, "clear_block", "software");
 
-	report.begin_section(SECTION_SOFTWARE);
-	report.add_header(__("Overview of Software Power Consumers"));
-	report.begin_table(TABLE_WIDE);
-	report.begin_row();
-	if (show_power) {
-		report.begin_cell(CELL_SOFTWARE_HEADER);
-		report.add(__("Power est."));
-	}
+	/* Set Table attributes, rows, and cols */
+	cols=7;
+	if (show_power)
+		cols=8;
 
-	report.begin_cell(CELL_SOFTWARE_HEADER);
-	report.add(__("Usage"));
-	report.begin_cell(CELL_SOFTWARE_HEADER);
-	report.add(__("Wakeups/s"));
-	report.begin_cell(CELL_SOFTWARE_HEADER);
-	report.add(__("GPU ops/s"));
-	report.begin_cell(CELL_SOFTWARE_HEADER);
-	report.add(__("Disk IO/s"));
-	report.begin_cell(CELL_SOFTWARE_HEADER);
-	report.add(__("GFX Wakeups/s"));
-	report.begin_cell(CELL_SOFTWARE_PROCESS);
-	report.add(__("Category"));
-	report.begin_cell(CELL_SOFTWARE_DESCRIPTION);
-	report.add(__("Description"));
+	idx=cols;
 
 	total = all_power.size();
-
 	if (total > 100)
 		total = 100;
 
+	rows=total+1;
+	table_attributes std_table_css;
+	init_nowarp_table_attr(&std_table_css, rows, cols);
+
+
+	/* Set Title attributes */
+	tag_attr title_attr;
+	init_title_attr(&title_attr);
+
+	/* Set array of data in row Major order */
+	string  software_data[cols * rows];
+	software_data[0]=__("Usage");
+	software_data[1]=__("Wakeups/s");
+	software_data[2]=__("GPU ops/s");
+	software_data[3]=__("Disk IO/s");
+	software_data[4]=__("GFX Wakeups/s");
+	software_data[5]=__("Category");
+	software_data[6]=__("Description");
+
+	if (show_power)
+		software_data[7]=__("PW Estimate");
+
+	sort(all_power.begin(), all_power.end(), power_cpu_sort);
+	show_power = global_power_valid();
+
 	for (i = 0; i < total; i++) {
 		char power[16];
 		char name[20];
@@ -943,7 +949,8 @@ void report_process_update_display(void)
 		if (strcmp(name, "Device") == 0)
 			continue;
 
-		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
+		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0
+				&& all_power[i]->Witts() == 0)
 			break;
 
 		usage[0] = 0;
@@ -958,7 +965,7 @@ void report_process_update_display(void)
 			sprintf(wakes, "%5.2f", 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);
+				all_power[i]->disk_hits / measurement_time);
 		sprintf(xwakes, "%5.1f", all_power[i]->xwakes / measurement_time);
 		if (!all_power[i]->show_events()) {
 			wakes[0] = 0;
@@ -975,27 +982,37 @@ void report_process_update_display(void)
 		if (all_power[i]->xwakes == 0)
 			xwakes[0] = 0;
 
-		report.begin_row(ROW_SOFTWARE);
+		software_data[idx]=string(usage);
+		idx+=1;
+
+		software_data[idx]=string(wakes);
+		idx+=1;
+
+		software_data[idx]=string(gpus);
+		idx+=1;
+
+		software_data[idx]=string(disks);
+		idx+=1;
+
+		software_data[idx]=string(xwakes);
+		idx+=1;
+
+		software_data[idx]=string(name);
+		idx+=1;
+
+		software_data[idx]=string(pretty_print(all_power[i]->description(), descr, 128));
+		idx+=1;
 		if (show_power) {
-			report.begin_cell(CELL_SOFTWARE_POWER);
-			report.add(power);
+			software_data[idx]=string(power);
+			idx+=1;
 		}
-
-		report.begin_cell(CELL_SOFTWARE_POWER);
-		report.add(usage);
-		report.begin_cell(CELL_SOFTWARE_POWER);
-		report.add(wakes);
-		report.begin_cell(CELL_SOFTWARE_POWER);
-		report.add(gpus);
-		report.begin_cell(CELL_SOFTWARE_POWER);
-		report.add(disks);
-		report.begin_cell(CELL_SOFTWARE_POWER);
-		report.add(xwakes);
-		report.begin_cell();
-		report.add(name);
-		report.begin_cell();
-		report.add(pretty_print(all_power[i]->description(), descr, 128));
 	}
+
+	/* Report Output */
+	report.add_div(&div_attr);
+	report.add_title(&title_attr, __("Overview of Software Power Consumers"));
+	report.add_table(software_data, &std_table_css);
+        report.end_div();
 }
 
 void report_summary(void)
diff --git a/src/report/report-data-html.cpp b/src/report/report-data-html.cpp
index 28732c9..f0d536d 100644
--- a/src/report/report-data-html.cpp
+++ b/src/report/report-data-html.cpp
@@ -71,7 +71,16 @@ void 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){
+	table_css->table_class="emphasis2";
+	table_css->tr_class="emph1";
+	table_css->th_class="emph_title";
+	table_css->td_class="no_wrap";
+	table_css->pos_table_title=T;
+	table_css->title_mod=0;
+	table_css->rows=rows;
+	table_css->cols=cols;
+}
 
 
 /* Other Helper Functions */
diff --git a/src/report/report-data-html.h b/src/report/report-data-html.h
index 61e75c0..d2d782b 100644
--- a/src/report/report-data-html.h
+++ b/src/report/report-data-html.h
@@ -53,6 +53,8 @@ init_core_table_attr(struct table_attributes *table_css, int title_mod,
 void
 init_cpu_table_attr(struct table_attributes *table_css, int title_mod,
 		int rows, int cols);
+void
+init_nowarp_table_attr(struct table_attributes *table_css, int rows, int cols);
 
 
 /* Other helper functions */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Powertop] [PATCH v3 19/31] report: redesign Software Information csv and html
@ 2013-12-10 20:14 Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2013-12-10 20:14 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 7010 bytes --]

On (11/18/13 12:27), Alexandra Yates wrote:
> Enabled "Overview of Software Power Consumers" section
> for csv and html report redesign, while preserving
> translation macros.
> 
> Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
> ---
>  src/process/do_process.cpp      |  113 ++++++++++++++++++++++-----------------
>  src/report/report-data-html.cpp |   11 +++-
>  src/report/report-data-html.h   |    2 +
>  3 files changed, 77 insertions(+), 49 deletions(-)
> 
> diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
> index c676978..6fc7a5b 100644
> --- a/src/process/do_process.cpp
> +++ b/src/process/do_process.cpp
> @@ -889,42 +889,48 @@ void report_process_update_display(void)
>  {
>  	unsigned int i;
>  	unsigned int total;
> +	int show_power, cols, rows, idx;
>  
> -	int show_power;
> -
> -	sort(all_power.begin(), all_power.end(), power_cpu_sort);
> -
> -	show_power = global_power_valid();
> +	/* div attr css_class and css_id */
> +	tag_attr div_attr;
> +	init_div(&div_attr, "clear_block", "software");
>  
> -	report.begin_section(SECTION_SOFTWARE);
> -	report.add_header(__("Overview of Software Power Consumers"));
> -	report.begin_table(TABLE_WIDE);
> -	report.begin_row();
> -	if (show_power) {
> -		report.begin_cell(CELL_SOFTWARE_HEADER);
> -		report.add(__("Power est."));
> -	}
> +	/* Set Table attributes, rows, and cols */
> +	cols=7;
> +	if (show_power)
> +		cols=8;
>  
> -	report.begin_cell(CELL_SOFTWARE_HEADER);
> -	report.add(__("Usage"));
> -	report.begin_cell(CELL_SOFTWARE_HEADER);
> -	report.add(__("Wakeups/s"));
> -	report.begin_cell(CELL_SOFTWARE_HEADER);
> -	report.add(__("GPU ops/s"));
> -	report.begin_cell(CELL_SOFTWARE_HEADER);
> -	report.add(__("Disk IO/s"));
> -	report.begin_cell(CELL_SOFTWARE_HEADER);
> -	report.add(__("GFX Wakeups/s"));
> -	report.begin_cell(CELL_SOFTWARE_PROCESS);
> -	report.add(__("Category"));
> -	report.begin_cell(CELL_SOFTWARE_DESCRIPTION);
> -	report.add(__("Description"));
> +	idx=cols;
>  
>  	total = all_power.size();
> -
>  	if (total > 100)
>  		total = 100;
>  
> +	rows=total+1;
> +	table_attributes std_table_css;
> +	init_nowarp_table_attr(&std_table_css, rows, cols);
> +
> +
> +	/* Set Title attributes */
> +	tag_attr title_attr;
> +	init_title_attr(&title_attr);
> +
> +	/* Set array of data in row Major order */
> +	string  software_data[cols * rows];
> +	software_data[0]=__("Usage");
> +	software_data[1]=__("Wakeups/s");
> +	software_data[2]=__("GPU ops/s");
> +	software_data[3]=__("Disk IO/s");
> +	software_data[4]=__("GFX Wakeups/s");
> +	software_data[5]=__("Category");
> +	software_data[6]=__("Description");
> +
> +	if (show_power)
> +		software_data[7]=__("PW Estimate");
> +
> +	sort(all_power.begin(), all_power.end(), power_cpu_sort);
> +	show_power = global_power_valid();
> +
>  	for (i = 0; i < total; i++) {
>  		char power[16];
>  		char name[20];
> @@ -943,7 +949,8 @@ void report_process_update_display(void)
>  		if (strcmp(name, "Device") == 0)
>  			continue;
>  
> -		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
> +		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0
> +				&& all_power[i]->Witts() == 0)
>  			break;
>  
>  		usage[0] = 0;
> @@ -958,7 +965,7 @@ void report_process_update_display(void)
>  			sprintf(wakes, "%5.2f", 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);
> +				all_power[i]->disk_hits / measurement_time);
>  		sprintf(xwakes, "%5.1f", all_power[i]->xwakes / measurement_time);
>  		if (!all_power[i]->show_events()) {
>  			wakes[0] = 0;
> @@ -975,27 +982,37 @@ void report_process_update_display(void)
>  		if (all_power[i]->xwakes == 0)
>  			xwakes[0] = 0;
>  
> -		report.begin_row(ROW_SOFTWARE);
> +		software_data[idx]=string(usage);
> +		idx+=1;
> +
> +		software_data[idx]=string(wakes);
> +		idx+=1;
> +
> +		software_data[idx]=string(gpus);
> +		idx+=1;
> +
> +		software_data[idx]=string(disks);
> +		idx+=1;
> +
> +		software_data[idx]=string(xwakes);
> +		idx+=1;
> +
> +		software_data[idx]=string(name);
> +		idx+=1;

/** just a side note*/

I think C++ can help us. we can just declare std::vector and push_back().

	-ss


> +		software_data[idx]=string(pretty_print(all_power[i]->description(), descr, 128));
> +		idx+=1;
>  		if (show_power) {
> -			report.begin_cell(CELL_SOFTWARE_POWER);
> -			report.add(power);
> +			software_data[idx]=string(power);
> +			idx+=1;
>  		}
> -
> -		report.begin_cell(CELL_SOFTWARE_POWER);
> -		report.add(usage);
> -		report.begin_cell(CELL_SOFTWARE_POWER);
> -		report.add(wakes);
> -		report.begin_cell(CELL_SOFTWARE_POWER);
> -		report.add(gpus);
> -		report.begin_cell(CELL_SOFTWARE_POWER);
> -		report.add(disks);
> -		report.begin_cell(CELL_SOFTWARE_POWER);
> -		report.add(xwakes);
> -		report.begin_cell();
> -		report.add(name);
> -		report.begin_cell();
> -		report.add(pretty_print(all_power[i]->description(), descr, 128));
>  	}
> +
> +	/* Report Output */
> +	report.add_div(&div_attr);
> +	report.add_title(&title_attr, __("Overview of Software Power Consumers"));
> +	report.add_table(software_data, &std_table_css);
> +        report.end_div();
>  }
>  
>  void report_summary(void)
> diff --git a/src/report/report-data-html.cpp b/src/report/report-data-html.cpp
> index 28732c9..f0d536d 100644
> --- a/src/report/report-data-html.cpp
> +++ b/src/report/report-data-html.cpp
> @@ -71,7 +71,16 @@ void 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){
> +	table_css->table_class="emphasis2";
> +	table_css->tr_class="emph1";
> +	table_css->th_class="emph_title";
> +	table_css->td_class="no_wrap";
> +	table_css->pos_table_title=T;
> +	table_css->title_mod=0;
> +	table_css->rows=rows;
> +	table_css->cols=cols;
> +}
>  
>  
>  /* Other Helper Functions */
> diff --git a/src/report/report-data-html.h b/src/report/report-data-html.h
> index 61e75c0..d2d782b 100644
> --- a/src/report/report-data-html.h
> +++ b/src/report/report-data-html.h
> @@ -53,6 +53,8 @@ init_core_table_attr(struct table_attributes *table_css, int title_mod,
>  void
>  init_cpu_table_attr(struct table_attributes *table_css, int title_mod,
>  		int rows, int cols);
> +void
> +init_nowarp_table_attr(struct table_attributes *table_css, int rows, int cols);
>  
>  
>  /* Other helper functions */
> -- 
> 1.7.9.5
> 
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-10 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 20:14 [Powertop] [PATCH v3 19/31] report: redesign Software Information csv and html Sergey Senozhatsky
  -- strict thread matches above, loose matches on Subject: below --
2013-11-18 20:27 Alexandra Yates

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.