[1/3] benchtests: Add --no-diff option to avoid diff calculation

Message ID 20180525155830.6864-2-leonardo.sandoval.gonzalez@linux.intel.com
State New, archived
Headers

Commit Message

leonardo.sandoval.gonzalez@linux.intel.com May 25, 2018, 3:58 p.m. UTC
  From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

Having the report with no diff numbers (percentages numbers
enclosed within parenthesis) makes column separation cleaner
(just spaces), allowing easier interaction with other tools.

	* benchtests/scripts/compare_string.py: Add --no-diff
	option to avoid diff calculation.
---
 ChangeLog                             |  5 +++++
 benchtests/scripts/compare_strings.py | 15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
  

Comments

Siddhesh Poyarekar May 27, 2018, 12:32 p.m. UTC | #1
On 05/25/2018 09:28 PM, leonardo.sandoval.gonzalez@linux.intel.com wrote:
> From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
> 
> Having the report with no diff numbers (percentages numbers
> enclosed within parenthesis) makes column separation cleaner
> (just spaces), allowing easier interaction with other tools.
> 
> 	* benchtests/scripts/compare_string.py: Add --no-diff
> 	option to avoid diff calculation.
> ---
>   ChangeLog                             |  5 +++++
>   benchtests/scripts/compare_strings.py | 15 +++++++++------
>   2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/ChangeLog b/ChangeLog
> index c7436c4f333..afddd77315a 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2018-05-25  Leonardo Sandoval  <leonardo.sandoval.gonzalez@intel.com>
> +
> +	* benchtests/scripts/compare_string.py: Add --no-diff option
> +	to avoid diff calculation.
> +
>   2018-05-24  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
>   	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
>   
> diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py
> index d37442076bf..ceeccea13b6 100755
> --- a/benchtests/scripts/compare_strings.py
> +++ b/benchtests/scripts/compare_strings.py
> @@ -79,7 +79,7 @@ def draw_graph(f, v, ifuncs, results):
>       pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight')
>   
>   
> -def process_results(results, attrs, base_func, graph):
> +def process_results(results, attrs, base_func, graph, no_diff):
>       """ Process results and print them
>   
>       Args:
> @@ -107,10 +107,11 @@ def process_results(results, attrs, base_func, graph):
>               graph_res[key] = res['timings']
>               for t in res['timings']:
>                   sys.stdout.write ('%12.2f' % t)
> -                if i != base_index:
> -                    base = res['timings'][base_index]
> -                    diff = (base - t) * 100 / base
> -                    sys.stdout.write (' (%6.2f%%)' % diff)
> +                if not no_diff:
> +                    if i != base_index:
> +                        base = res['timings'][base_index]
> +                        diff = (base - t) * 100 / base
> +                        sys.stdout.write (' (%6.2f%%)' % diff)
>                   sys.stdout.write('\t')
>                   i = i + 1
>               print('')
> @@ -132,7 +133,7 @@ def main(args):
>       attrs = args.attributes.split(',')
>   
>       results = parse_file(args.input, args.schema)
> -    process_results(results, attrs, base_func, args.graph)
> +    process_results(results, attrs, base_func, args.graph, args.no_diff)
>   
>   
>   if __name__ == '__main__':
> @@ -152,6 +153,8 @@ if __name__ == '__main__':
>                           help='IFUNC variant to set as baseline.')
>       parser.add_argument('-g', '--graph', action='store_true',
>                           help='Generate a graph from results.')
> +    parser.add_argument('--no-diff', action='store_true',
> +                        help='Do not include diff on .')

Please change the help description to "Do not print the difference from 
baseline" to be clearer.  OK with that change.

Thanks,
Siddhesh

>   
>       args = parser.parse_args()
>       main(args)
>
  

Patch

diff --git a/ChangeLog b/ChangeLog
index c7436c4f333..afddd77315a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@ 
+2018-05-25  Leonardo Sandoval  <leonardo.sandoval.gonzalez@intel.com>
+
+	* benchtests/scripts/compare_string.py: Add --no-diff option
+	to avoid diff calculation.
+
 2018-05-24  Tulio Magno Quites Machado Filho  <tuliom@linux.ibm.com>
 	    Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
diff --git a/benchtests/scripts/compare_strings.py b/benchtests/scripts/compare_strings.py
index d37442076bf..ceeccea13b6 100755
--- a/benchtests/scripts/compare_strings.py
+++ b/benchtests/scripts/compare_strings.py
@@ -79,7 +79,7 @@  def draw_graph(f, v, ifuncs, results):
     pylab.savefig('%s-%s.png' % (f, v), bbox_inches='tight')
 
 
-def process_results(results, attrs, base_func, graph):
+def process_results(results, attrs, base_func, graph, no_diff):
     """ Process results and print them
 
     Args:
@@ -107,10 +107,11 @@  def process_results(results, attrs, base_func, graph):
             graph_res[key] = res['timings']
             for t in res['timings']:
                 sys.stdout.write ('%12.2f' % t)
-                if i != base_index:
-                    base = res['timings'][base_index]
-                    diff = (base - t) * 100 / base
-                    sys.stdout.write (' (%6.2f%%)' % diff)
+                if not no_diff:
+                    if i != base_index:
+                        base = res['timings'][base_index]
+                        diff = (base - t) * 100 / base
+                        sys.stdout.write (' (%6.2f%%)' % diff)
                 sys.stdout.write('\t')
                 i = i + 1
             print('')
@@ -132,7 +133,7 @@  def main(args):
     attrs = args.attributes.split(',')
 
     results = parse_file(args.input, args.schema)
-    process_results(results, attrs, base_func, args.graph)
+    process_results(results, attrs, base_func, args.graph, args.no_diff)
 
 
 if __name__ == '__main__':
@@ -152,6 +153,8 @@  if __name__ == '__main__':
                         help='IFUNC variant to set as baseline.')
     parser.add_argument('-g', '--graph', action='store_true',
                         help='Generate a graph from results.')
+    parser.add_argument('--no-diff', action='store_true',
+                        help='Do not include diff on .')
 
     args = parser.parse_args()
     main(args)