Signed-off-by: Rhys Perry <pendingchao...@gmail.com> --- nv-report.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/nv-report.py b/nv-report.py index 1c1491af0a..703fcf4571 100644 --- a/nv-report.py +++ b/nv-report.py @@ -81,13 +81,16 @@ def read_stats(fname): return stats -def diff(a, b): +def get_diff_percentage(a, b): percentage = 0. if a != 0.: percentage = b * 100. / a - 100. elif b != 0.: percentage = float('inf') - return "%d -> %d (%.2f%%)" % (a, b, percentage) + return percentage + +def diff(a, b): + return "%d -> %d (%.2f%%)" % (a, b, get_diff_percentage(a, b)) def print_summary(before, after, keys, only_affected): exclude = set() @@ -133,10 +136,48 @@ def print_helped_hurt(keys, before, after): print "%10d " % getattr(hurt, attr), print +def print_top(before, after, keys, attr, num): + candidates = [] + for key in keys: + a = after.stats[key] + b = before.stats[key] + aa = getattr(a, attr) + ba = getattr(b, attr) + if aa - ba == 0: + continue + candidates.append((key, abs(get_diff_percentage(ba, aa)), ba, aa)) + candidates.sort(key = lambda a: a[1], reverse=True) + candidates = candidates[:num] + + print "top %d affected programs for %s" % (num, attr) + for key, _, beforestat, afterstat in candidates: + print " %s : %s " % (key, diff(beforestat, afterstat)) + +def print_smallest(before, after, keys, attr, num): + candidates = [] + for key in keys: + a = after.stats[key] + b = before.stats[key] + aa = getattr(a, attr) + ba = getattr(b, attr) + if aa - ba == 0: + continue + candidates.append((key, after.stats[key].inst)) + candidates.sort(key = lambda a: a[1]) + candidates = candidates[:num] + + print "smallest %d affected programs for %s" % (num, attr) + for key, size in candidates: + print " %s : %d instructions" % (key, size) + def main(argv): parser = argparse.ArgumentParser(description=DESCRIPTION) parser.add_argument('before', help="the baseline run") parser.add_argument('after', help="the run to compare against the baseline") + parser.add_argument('--top', action="append", nargs=2, metavar=("ATTR", "N"), + help="also show the top n programs affected for attr") + parser.add_argument('--smallest', action="append", nargs=2, metavar=("ATTR", "N"), + help="also show the smallest n programs affected for attr") args = parser.parse_args(argv[1:]) before = read_stats(args.before) @@ -155,6 +196,14 @@ def main(argv): print print_helped_hurt(keys, before, after) + for attr, num in args.top if args.top else []: + print + print_top(before, after, keys, attr, int(num)) + + for attr, num in args.smallest if args.smallest else []: + print + print_smallest(before, after, keys, attr, int(num)) + if __name__ == "__main__": main(sys.argv) -- 2.14.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev