[Mesa-dev] [PATCH shader-db v2 3/5] nv-report: additionally report changes in only affected programs
Rhys Perry
pendingchaos02 at gmail.com
Sun Aug 5 12:06:10 UTC 2018
v2: change compute_totals() to take an include instead of an exclude list
v2: show number of affected programs
v2: flip around the shared and affected statistics
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
nv-report.py | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/nv-report.py b/nv-report.py
index 91007625ff..5049207c22 100644
--- a/nv-report.py
+++ b/nv-report.py
@@ -35,6 +35,9 @@ class Stat(object):
return False
return True
+ def __ne__(self, other):
+ return not (self == other)
+
class Stats(object):
def __init__(self):
@@ -46,9 +49,9 @@ class Stats(object):
assert name not in self.stats, name
self.stats[name] = stat
- def compute_totals(self):
+ def compute_totals(self, stat_keys):
for attr in STATS:
- stats = self.stats.itervalues()
+ stats = [self.stats[key] for key in stat_keys]
setattr(self, attr, sum(getattr(stat, attr) for stat in stats))
RE = {
@@ -80,14 +83,24 @@ def diff(a, b):
percentage = float('inf')
return "%d -> %d (%.2f%%)" % (a, b, percentage)
-def print_summary(before, after):
- before.compute_totals()
- after.compute_totals()
+def print_summary(before, after, keys, only_affected):
+ if only_affected:
+ stat_keys = [key for key in keys if before.stats[key] != after.stats[key]]
+ else:
+ stat_keys = keys
+ before.compute_totals(stat_keys)
+ after.compute_totals(stat_keys)
- print "total instructions in shared programs :", diff(before.inst, after.inst)
- print "total gprs used in shared programs :", diff(before.gpr, after.gpr)
- print "total shared used in shared programs :", diff(before.shared, after.shared)
- print "total local used in shared programs :", diff(before.local, after.local)
+ if only_affected:
+ affected = len(stat_keys)
+ programs = "%d (%.2f%%) affected programs" % (affected, affected/float(len(keys))*100.0)
+ else:
+ programs = "shared programs"
+
+ print "total instructions in %s :" % programs, diff(before.inst, after.inst)
+ print "total gprs used in %s :" % programs, diff(before.gpr, after.gpr)
+ print "total shared used in %s :" % programs, diff(before.shared, after.shared)
+ print "total local used in %s :" % programs, diff(before.local, after.local)
def print_helped_hurt(keys, before, after):
helped = Stat()
@@ -129,7 +142,9 @@ def main(argv):
continue
keys.add(key)
- print_summary(before, after)
+ print_summary(before, after, keys, True)
+ print
+ print_summary(before, after, keys, False)
print
print_helped_hurt(keys, before, after)
--
2.14.4
More information about the mesa-dev
mailing list