Re: [Fuego] [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation error
"Bird, Tim" <[email protected]> Thu, 22 Sep 2022 22:44:37 +0000
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <BYAPR13MB250339B544D906709AE6F92BFD4E9@BYAPR13MB2503.namprd13.prod.outlook.com> |
Sireesha, Please see my comments, and replacement patch below. > -----Original Message----- > Subject: RE: [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation er= ror >=20 > Dear Tim, >=20 > Please review the below change. >=20 > Thanks & Regards > Sireesha >=20 > > -----Original Message----- > > From: [email protected] <sireesha.nakkala@toshiba- > > tsip.com> > > Sent: Wednesday, August 24, 2022 2:43 PM > > To: [email protected] > > Cc: nakkala sireesha(=1B$B#T#S#I#P=1B(B TMIEC ODG Porting) > > <[email protected]>; [email protected]; > > dinesh kumar(=1B$B#T#S#I#P=1B(B TMIEC ODG Porting) <dinesh.kumar@toshib= a- > > tsip.com>; hayashi kazuhiro(=1B$BNS=1B(B =1B$BOB9(=1B(B =1B$B""#S#W#C"~= #A#C#T=1B(B) > > <[email protected]> > > Subject: [PATCH] Benchmark.lmbench2-parser.py: Reslove indentation erro= r > > > > From: sireesha <[email protected]> > > > > This was failing while processing the results, fixed indentation proble= m > > > > Signed-off-by: sireesha <[email protected]> > > --- > > 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 =3D > > str(float(value.rstrip(".G"))*1000*1000*1000) > > elif value[-1] =3D=3D 'T': > > value =3D > > 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 whitesp= ace in this script. > > t_index +=3D 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 al= l 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 intellig= ent. But for now, I've applied the patch below, and pushed it to the master bran= ch. Thanks very much for the report. -- Tim From 68f8a43715f62448278ad45bd1b35fed6005551a Mon Sep 17 00:00:00 2001 From: Tim Bird <[email protected]> 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 <[email protected]> Signed-off-by: Tim Bird <[email protected]> --- 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 =3D [] print lines =20 for line in lines: - result =3D 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] =3D result[0].replace(' ', ' 0 ') - - test_res =3D result[0].rstrip('\n').split(' ') - - print "test_res =3D %s" % (test_res) - - if 0 < t_index < 9: - for value in test_res: - if len(value) > 0: - if value[-1] =3D=3D 'K': - value =3D str(float(value.= rstrip(".K"))*1000) - elif value[-1] =3D=3D 'M': - value =3D str(float(value.= rstrip(".M"))*1000*1000) - elif value[-1] =3D=3D 'G': - value =3D str(float(value.= rstrip(".G"))*1000*1000*1000) - elif value[-1] =3D=3D 'T': - value =3D str(float(value.= rstrip(".T"))*1000*1000*1000*1000) - sublist.append(value) - t_index +=3D 1 + result =3D 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] =3D result[0].replace(' ', ' 0 ') + test_res =3D result[0].rstrip('\n').split(' ') + + print "test_res =3D %s" % (test_res) + + if 0 < t_index < 9: + for value in test_res: + if len(value) > 0: + if value[-1] =3D=3D 'K': + value =3D str(float(value.rstrip(".K"))*1000) + elif value[-1] =3D=3D 'M': + value =3D str(float(value.rstrip(".M"))*1000*1000) + elif value[-1] =3D=3D 'G': + value =3D str(float(value.rstrip(".G"))*1000*1000*= 1000) + elif value[-1] =3D=3D 'T': + value =3D str(float(value.rstrip(".T"))*1000*1000*= 1000*1000) + sublist.append(value) + t_index +=3D 1 =20 cur_file.close() =20 if len(sublist) =3D=3D 0: - sys.exit("\nparser: Fuego error reason: No results found\n") + sys.exit("\nparser: Fuego error reason: No results found\n") =20 cur_dict["Basic_Integer.Bit"] =3D sublist[0] cur_dict["Basic_Integer.Add"] =3D sublist[1] @@ -105,7 +104,6 @@ cur_dict["Memory_Latencies.Main_mem"] =3D sublist[48] #cur_dict["Memory_Latencies.Guesses"] =3D sublist[49] cur_dict["Memory_Latencies.Rand_mem"] =3D sublist[50] =20 - -print "cur_dist =3D %s" % (cur_dict) +print "cur_dict =3D %s" % (cur_dict) =20 sys.exit(plib.process_data(ref_section_pat, cur_dict, 'xl', ' ')) --=20 2.25.1 =20