From c6a5ea6b85ac212af6a914a39a5429f8dd8c05a4 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Tue, 7 Apr 2020 18:18:33 -0700 Subject: [PATCH] [lit] Print slowest test first when timing tests lit supports `--time-tests` which will report the 20 slowest tests and print a nice histogram for test times. This change prints this list and the histogram rows by decreasing test times. After all, we are most interested in the slowest tests. --- utils/lit/lit/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/lit/lit/util.py b/utils/lit/lit/util.py index ab51988e21e..ac75f248dcb 100644 --- a/utils/lit/lit/util.py +++ b/utils/lit/lit/util.py @@ -291,7 +291,7 @@ def printHistogram(items, title='Items'): hr = '-' * (barW + 34) print('\nSlowest %s:' % title) print(hr) - for name, value in items[-20:]: + for name, value in reversed(items[-20:]): print('%.2fs: %s' % (value, name)) print('\n%s Times:' % title) print(hr) @@ -304,7 +304,7 @@ def printHistogram(items, title='Items'): 'Percentage'.center(barW), 'Count'.center(cDigits * 2 + 1))) print(hr) - for i, row in enumerate(histo): + for i, row in reversed(list(enumerate(histo))): pct = float(len(row)) / len(items) w = int(barW * pct) print('[%*.*fs,%*.*fs) :: [%s%s] :: [%*d/%*d]' % (