From 16cb1705fe546b09f5099b2314ba28d5c6c5d81b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 29 Aug 2012 21:36:14 -0700 Subject: report.py: Also port to Python 3. Aside from the usual print() changes, this requires converting the hurt list sorting from the "cmp" method (which was removed) to the "key" approach. --- report.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/report.py b/report.py index 0f79a4d..652e89a 100755 --- a/report.py +++ b/report.py @@ -12,7 +12,7 @@ Usage: %(progName)s Options: -h, --help Show this message """ - print USAGE % {'progName': sys.argv[0]} + print(USAGE % {'progName': sys.argv[0]}) sys.exit(1) def get_results(filename): @@ -107,38 +107,31 @@ def main(): helped.sort() for r in helped: - print "helped: " + r + print("helped: " + r) if len(helped) > 0: - print "" + print("") - def hurt_sort(k1, k2): - if (float(after[k1] - before[k1]) / before[k1] > - float(after[k2] - before[k2]) / before[k2]): - return 1 - else: - return -1 - - hurt.sort(cmp=hurt_sort) + hurt.sort(key=lambda k: float(after[k] - before[k]) / before[k]) for p in hurt: namestr = p[0] + " " + p[1] - print "HURT: " + get_result_string(namestr, before[p], after[p]) + print("HURT: " + get_result_string(namestr, before[p], after[p])) if len(hurt) > 0: - print "" + print("") lost.sort() for p in lost: - print "LOST: " + p + print("LOST: " + p) if len(lost) > 0: - print "" + print("") gained.sort() for p in gained: - print "GAINED: " + p + print("GAINED: " + p) if len(gained) > 0: - print "" + print("") - print "total instructions in shared programs: " + change(total_before, total_after) - print "instructions in affected programs: " + change(affected_before, affected_after) + print("total instructions in shared programs: " + change(total_before, total_after)) + print("instructions in affected programs: " + change(affected_before, affected_after)) if __name__ == "__main__": main() -- cgit v1.2.3