[test-suite] r289275 - Revert "utils/compare.py: Fix problems when not showing the diff column"

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 13:30:32 PST 2016


Author: matze
Date: Fri Dec  9 15:30:31 2016
New Revision: 289275

URL: http://llvm.org/viewvc/llvm-project?rev=289275&view=rev
Log:
Revert "utils/compare.py: Fix problems when not showing the diff column"

This broke more than it fixed, revert for now.

This reverts commit r289268.

Modified:
    test-suite/trunk/utils/compare.py

Modified: test-suite/trunk/utils/compare.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/utils/compare.py?rev=289275&r1=289274&r2=289275&view=diff
==============================================================================
--- test-suite/trunk/utils/compare.py (original)
+++ test-suite/trunk/utils/compare.py Fri Dec  9 15:30:31 2016
@@ -99,6 +99,8 @@ def readmulti(filenames):
     return d
 
 def add_diff_column(d, absolute_diff=False):
+    values = d.unstack(level=0)
+
     has_two_runs = d.index.get_level_values(0).nunique() == 2
     if has_two_runs:
         values0 = values.iloc[:,0]
@@ -143,8 +145,6 @@ def print_filter_stats(reason, before, a
 # Truncate a string to a maximum length by keeping a prefix, a suffix and ...
 # in the middle
 def truncate(string, prefix_len, suffix_len):
-    if string==():
-        return ""
     return re.sub("^(.{%d}).*(.{%d})$" % (prefix_len, suffix_len),
                   "\g<1>...\g<2>", string)
 
@@ -183,13 +183,14 @@ def format_diff(value):
     else:
         return "%-5d" % value
 
-def print_result(d, limit_output=True, shorten_names=True, sortkey=None):
-    if sortkey is not None:
-        # sort (TODO: is there a more elegant way than create+drop a column?)
-        d['$sortkey'] = d[sortkey].abs()
-        d = d.sort_values("$sortkey", ascending=False)
-        del d['$sortkey']
-
+def print_result(d, limit_output=True, shorten_names=True,
+                 show_diff_column=True, sortkey='diff'):
+    # sort (TODO: is there a more elegant way than create+drop a column?)
+    d['$sortkey'] = d[sortkey].abs()
+    d = d.sort_values("$sortkey", ascending=False)
+    del d['$sortkey']
+    if not show_diff_column:
+        del d['diff']
     dataout = d
     if limit_output:
         # Take 15 topmost elements
@@ -314,12 +315,9 @@ if __name__ == "__main__":
     print "Metric: %s" % metric
     if len(metric) > 0:
         data = data[metrics]
-    data = data.unstack(level=0)
+    data = add_diff_column(data)
 
-    sortkey = None
-    if config.show_diff:
-        data = add_diff_column(data)
-        sortkey = 'diff'
+    sortkey = 'diff'
     if len(config.files) == 1:
         sortkey = data.columns[0]
 
@@ -327,4 +325,4 @@ if __name__ == "__main__":
     print ""
     shorten_names = not config.full
     limit_output = (not config.all) and (not config.full)
-    print_result(data, limit_output, shorten_names, sortkey)
+    print_result(data, limit_output, shorten_names, config.show_diff, sortkey)




More information about the llvm-commits mailing list