python: Apply Black formatter to Python files

The command executed was `black src configs tests util`.

Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2022-07-05 11:02:25 -07:00
committed by Giacomo Travaglini
parent 1cfaa8da83
commit 787204c92d
980 changed files with 35668 additions and 22233 deletions

View File

@@ -33,7 +33,8 @@ import re
import getopt
from categories import *
def category(app,sym):
def category(app, sym):
if re.search("vmlinux-2.6", app):
name = sym
else:
@@ -45,24 +46,25 @@ def category(app,sym):
if regexp.match(name):
return cat
print("no match for symbol %s" % name)
return 'other'
return "other"
try:
(opts, files) = getopt.getopt(sys.argv[1:], 'i')
(opts, files) = getopt.getopt(sys.argv[1:], "i")
except getopt.GetoptError:
print("usage", sys.argv[0], "[-i] <files>")
sys.exit(2)
print("usage", sys.argv[0], "[-i] <files>")
sys.exit(2)
showidle = True
for o,v in opts:
for o, v in opts:
if o == "-i":
showidle = False
print(files)
f = open(files.pop())
total = 0
prof = {}
linenum = 0
linenum = 0
for line in f.readlines():
line = re.sub("\(no symbols\)", "nosym", line)
line = re.sub("anonymous.*", "nosym", line)
@@ -70,23 +72,31 @@ for line in f.readlines():
if linenum < 4:
continue
(count, percent, app, sym) = line.split()
#total += int(count)
cat = category(app,sym)
if cat != 'idle' or showidle:
total += int(count)
prof[cat] = prof.get(cat,0) + int(count)
# total += int(count)
cat = category(app, sym)
if cat != "idle" or showidle:
total += int(count)
prof[cat] = prof.get(cat, 0) + int(count)
cats = ['other', 'user', 'copy', 'bufmgt', 'stack', 'driver', 'interrupt', 'alignment' ]
cats = [
"other",
"user",
"copy",
"bufmgt",
"stack",
"driver",
"interrupt",
"alignment",
]
if showidle:
cats.insert(0,'idle')
cats.insert(0, "idle")
#syms = [(i[1], i[0]) for i in prof.items()]
#syms.sort()
#for i in range(len(syms)):
# syms = [(i[1], i[0]) for i in prof.items()]
# syms.sort()
# for i in range(len(syms)):
# print "%s -- %5.1f%% " % (prof[i][1], 100 * float(prof[i][0])/float(total))
for d in cats:
if d in prof:
print("%s -- %5.1f%% " % (d, 100 * float(prof[d])/float(total)))
print("%s -- %5.1f%% " % (d, 100 * float(prof[d]) / float(total)))