All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
@ 2022-08-24  9:13 sireesha.nakkala
  2022-09-15  6:54 ` sireesha.nakkala
  0 siblings, 1 reply; 3+ messages in thread
From: sireesha.nakkala @ 2022-08-24  9:13 UTC (permalink / raw)
  To: tim.bird; +Cc: kazuhiro3.hayashi, dinesh.kumar, sireesha, fuego

From: sireesha <sireesha.nakkala@toshiba-tsip.com>

This was failing while processing the results, fixed indentation problem

Signed-off-by: sireesha <sireesha.nakkala@toshiba-tsip.com>
---
 tests/Benchmark.lmbench2/parser.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Benchmark.lmbench2/parser.py b/tests/Benchmark.lmbench2/parser.py
index 96732e3..32e0fc5 100755
--- a/tests/Benchmark.lmbench2/parser.py
+++ b/tests/Benchmark.lmbench2/parser.py
@@ -44,7 +44,7 @@ for line in lines:
                                                 value = str(float(value.rstrip(".G"))*1000*1000*1000)
                                         elif value[-1] == 'T':
                                                 value = str(float(value.rstrip(".T"))*1000*1000*1000*1000)
-					sublist.append(value)
+                                        sublist.append(value)
 		t_index += 1
 
 cur_file.close()
-- 
2.20.1



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

* Re: [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
  2022-08-24  9:13 [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error sireesha.nakkala
@ 2022-09-15  6:54 ` sireesha.nakkala
  2022-09-22 22:44   ` Bird, Tim
  0 siblings, 1 reply; 3+ messages in thread
From: sireesha.nakkala @ 2022-09-15  6:54 UTC (permalink / raw)
  To: tim.bird; +Cc: kazuhiro3.hayashi, dinesh.kumar, sireesha.nakkala, fuego

Dear Tim,

Please review the below change.

Thanks & Regards
Sireesha

> -----Original Message-----
> From: sireesha.nakkala@toshiba-tsip.com <sireesha.nakkala@toshiba-
> tsip.com>
> Sent: Wednesday, August 24, 2022 2:43 PM
> To: tim.bird@sony.com
> Cc: nakkala sireesha(TSIP TMIEC ODG Porting)
> <sireesha.nakkala@toshiba-tsip.com>; fuego@lists.linuxfoundation.org;
> dinesh kumar(TSIP TMIEC ODG Porting) <dinesh.kumar@toshiba-
> tsip.com>; hayashi kazuhiro(林 和宏 □SWC◯ACT)
> <kazuhiro3.hayashi@toshiba.co.jp>
> Subject: [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
> 
> From: sireesha <sireesha.nakkala@toshiba-tsip.com>
> 
> This was failing while processing the results, fixed indentation problem
> 
> Signed-off-by: sireesha <sireesha.nakkala@toshiba-tsip.com>
> ---
>  tests/Benchmark.lmbench2/parser.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/Benchmark.lmbench2/parser.py
> b/tests/Benchmark.lmbench2/parser.py
> index 96732e3..32e0fc5 100755
> --- a/tests/Benchmark.lmbench2/parser.py
> +++ b/tests/Benchmark.lmbench2/parser.py
> @@ -44,7 +44,7 @@ for line in lines:
>                                                  value =
> str(float(value.rstrip(".G"))*1000*1000*1000)
>                                          elif value[-1] == 'T':
>                                                  value =
> str(float(value.rstrip(".T"))*1000*1000*1000*1000)
> -					sublist.append(value)
> +                                        sublist.append(value)
>  		t_index += 1
> 
>  cur_file.close()
> --
> 2.20.1



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

* Re: [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
  2022-09-15  6:54 ` sireesha.nakkala
@ 2022-09-22 22:44   ` Bird, Tim
  0 siblings, 0 replies; 3+ messages in thread
From: Bird, Tim @ 2022-09-22 22:44 UTC (permalink / raw)
  To: sireesha.nakkala; +Cc: kazuhiro3.hayashi, dinesh.kumar, fuego

Sireesha,

Please see my comments, and replacement patch below.

> -----Original Message-----
> Subject: RE: [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
> 
> Dear Tim,
> 
> Please review the below change.
> 
> Thanks & Regards
> Sireesha
> 
> > -----Original Message-----
> > From: sireesha.nakkala@toshiba-tsip.com <sireesha.nakkala@toshiba-
> > tsip.com>
> > Sent: Wednesday, August 24, 2022 2:43 PM
> > To: tim.bird@sony.com
> > Cc: nakkala sireesha(TSIP TMIEC ODG Porting)
> > <sireesha.nakkala@toshiba-tsip.com>; fuego@lists.linuxfoundation.org;
> > dinesh kumar(TSIP TMIEC ODG Porting) <dinesh.kumar@toshiba-
> > tsip.com>; hayashi kazuhiro(林 和宏 □SWC◯ACT)
> > <kazuhiro3.hayashi@toshiba.co.jp>
> > Subject: [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
> >
> > From: sireesha <sireesha.nakkala@toshiba-tsip.com>
> >
> > This was failing while processing the results, fixed indentation problem
> >
> > Signed-off-by: sireesha <sireesha.nakkala@toshiba-tsip.com>
> > ---
> >  tests/Benchmark.lmbench2/parser.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tests/Benchmark.lmbench2/parser.py
> > b/tests/Benchmark.lmbench2/parser.py
> > index 96732e3..32e0fc5 100755
> > --- a/tests/Benchmark.lmbench2/parser.py
> > +++ b/tests/Benchmark.lmbench2/parser.py
> > @@ -44,7 +44,7 @@ for line in lines:
> >                                                  value =
> > str(float(value.rstrip(".G"))*1000*1000*1000)
> >                                          elif value[-1] == 'T':
> >                                                  value =
> > str(float(value.rstrip(".T"))*1000*1000*1000*1000)
> > -					sublist.append(value)
> > +                                        sublist.append(value)

This patch is correct, but it doesn't fix a deeper problem with the whitespace
in this script.

> >  		t_index += 1
> >
> >  cur_file.close()
> > --
> > 2.20.1

Some background...
In April, I applied a patch to parser.py that handled multiplier suffixes
on values.  This patch introduced the bug you found, since it used
spaces instead of tabs, with the wrong indentation for the if/elif blocks.

Having a mixture of spaces and tabs for indentation in a python script
is bad form, and is very error prone.  As a result, I decided to convert all the tabs
in the script to spaces, and adjust the line lengths to be correct.

In reviewing the overall operation of this parser, it's quite fragile.  It relies
on a specific ordering of sub-categories of metrics, and metrics themselves,
which also seems quite error prone.  This parsing would almost surely break if
anyone did something fancy with arguments to lmbench (which would affect
which measurements it output).

I'll try to find some time to re-work this parser to be a bit more intelligent.
But for now, I've applied the patch below, and pushed it to the master branch.

Thanks very much for the report.

 -- Tim
From 68f8a43715f62448278ad45bd1b35fed6005551a Mon Sep 17 00:00:00 2001
From: Tim Bird <tim.bird@sony.com>
Date: Thu, 22 Sep 2022 16:00:24 -0600
Subject: [PATCH] lmbench2: fix whitespace in parser.py

The parser.py script for Benchmark.lmbench2 had mixed
spaces and tabs, resulting in confusion and bugs.
commit db4c8d7 by sai ashrith replaced some uses of
tabs with spaces, but it ended up introducing subtle
bugs because the spacing was off.

Replace all tabs in the document with 4 spaces (that is,
use tabstops of 4 spaces), and adjust the spacing of
the recently inserted code to be semantically correct.

Reported by: sireesha <sireesha.nakkala@toshiba-tsip.com>
Signed-off-by: Tim Bird <tim.bird@sony.com>
---
 tests/Benchmark.lmbench2/parser.py | 52 ++++++++++++++----------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/tests/Benchmark.lmbench2/parser.py b/tests/Benchmark.lmbench2/parser.py
index a4a3a6a..f06f132 100755
--- a/tests/Benchmark.lmbench2/parser.py
+++ b/tests/Benchmark.lmbench2/parser.py
@@ -22,35 +22,34 @@ sublist = []
 print lines
 
 for line in lines:
-	result = cur_search_pat.findall(line)
-	if result and len(result[0]) > 0:
-		print 'result: ', result
-
-		# Ugly hack to work around invalid processing of empty cells
-		result[0] = result[0].replace('       ', '     0 ')
-
-		test_res = result[0].rstrip('\n').split(' ')
-
-                print "test_res = %s" % (test_res)
-
-		if 0 < t_index < 9:
-			for value in test_res:
-				if len(value) > 0:
-                                        if value[-1] == 'K':
-                                                value = str(float(value.rstrip(".K"))*1000)
-                                        elif value[-1] == 'M':
-                                                value = str(float(value.rstrip(".M"))*1000*1000)
-                                        elif value[-1] == 'G':
-                                                value = str(float(value.rstrip(".G"))*1000*1000*1000)
-                                        elif value[-1] == 'T':
-                                                value = str(float(value.rstrip(".T"))*1000*1000*1000*1000)
-					sublist.append(value)
-		t_index += 1
+    result = cur_search_pat.findall(line)
+    if result and len(result[0]) > 0:
+        print 'result: ', result
+
+        # Ugly hack to work around invalid processing of empty cells
+        result[0] = result[0].replace('       ', '     0 ')
+        test_res = result[0].rstrip('\n').split(' ')
+
+        print "test_res = %s" % (test_res)
+
+        if 0 < t_index < 9:
+            for value in test_res:
+                if len(value) > 0:
+                    if value[-1] == 'K':
+                        value = str(float(value.rstrip(".K"))*1000)
+                    elif value[-1] == 'M':
+                        value = str(float(value.rstrip(".M"))*1000*1000)
+                    elif value[-1] == 'G':
+                        value = str(float(value.rstrip(".G"))*1000*1000*1000)
+                    elif value[-1] == 'T':
+                        value = str(float(value.rstrip(".T"))*1000*1000*1000*1000)
+                    sublist.append(value)
+        t_index += 1
 
 cur_file.close()
 
 if len(sublist) == 0:
-	sys.exit("\nparser: Fuego error reason: No results found\n")
+    sys.exit("\nparser: Fuego error reason: No results found\n")
 
 cur_dict["Basic_Integer.Bit"] = sublist[0]
 cur_dict["Basic_Integer.Add"] = sublist[1]
@@ -105,7 +104,6 @@ cur_dict["Memory_Latencies.Main_mem"] = sublist[48]
 #cur_dict["Memory_Latencies.Guesses"] = sublist[49]
 cur_dict["Memory_Latencies.Rand_mem"] = sublist[50]
 
-
-print "cur_dist = %s" % (cur_dict)
+print "cur_dict = %s" % (cur_dict)
 
 sys.exit(plib.process_data(ref_section_pat, cur_dict, 'xl', ' '))
-- 
2.25.1


 


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

end of thread, other threads:[~2022-09-22 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24  9:13 [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error sireesha.nakkala
2022-09-15  6:54 ` sireesha.nakkala
2022-09-22 22:44   ` Bird, Tim

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.