aboutsummaryrefslogtreecommitdiff
path: root/cros_utils/tabulator.py
diff options
context:
space:
mode:
authorDenis Nikitin <denik@google.com>2020-03-18 18:11:24 -0700
committerDenis Nikitin <denik@chromium.org>2020-03-20 01:10:39 +0000
commit66ee2dc562b90cfbf21c41d477e017dfd4ba9e12 (patch)
tree4fccba358f7cfb6827bd5530200d5a7fa345d8ff /cros_utils/tabulator.py
parent6a5688fb60152eb4117345d97e65efbfe168f337 (diff)
downloadtoolchain-utils-66ee2dc562b90cfbf21c41d477e017dfd4ba9e12.tar.gz
cros_utils: Do not sort keys by default
Add a sort option NO_SORT in TableGenerator and make it default. Before we had rows in the table sorted by key-name which mixed up the test scores with cpufreq_*, cputemp_* data and made it hard to locate the most important information. The change solves the problem by leaving the keys in the original order which will guarantee that retval and cpu stats will always be at the end of the table. BUG=None TEST=rendering.desktop and loading.desktop show scores in the beginning of the table. Change-Id: I5b2d75db20549eae264db9ca809ccd634e743510 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2108572 Tested-by: Denis Nikitin <denik@chromium.org> Commit-Queue: Denis Nikitin <denik@chromium.org> Reviewed-by: Bob Haarman <inglorion@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'cros_utils/tabulator.py')
-rw-r--r--cros_utils/tabulator.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cros_utils/tabulator.py b/cros_utils/tabulator.py
index 5029ceee..3d5f2aed 100644
--- a/cros_utils/tabulator.py
+++ b/cros_utils/tabulator.py
@@ -64,6 +64,7 @@ table:
from __future__ import division
from __future__ import print_function
+import collections
import getpass
import math
import sys
@@ -112,21 +113,22 @@ class TableGenerator(object):
SORT_BY_KEYS_DESC = 1
SORT_BY_VALUES = 2
SORT_BY_VALUES_DESC = 3
+ NO_SORT = 4
MISSING_VALUE = 'x'
- def __init__(self, d, l, sort=SORT_BY_KEYS, key_name='keys'):
+ def __init__(self, d, l, sort=NO_SORT, key_name='keys'):
self._runs = d
self._labels = l
self._sort = sort
self._key_name = key_name
def _AggregateKeys(self):
- keys = set([])
+ keys = collections.OrderedDict()
for run_list in self._runs:
for run in run_list:
- keys = keys.union(run.keys())
- return keys
+ keys.update(dict.fromkeys(run.keys()))
+ return list(keys.keys())
def _GetHighestValue(self, key):
values = []
@@ -159,6 +161,8 @@ class TableGenerator(object):
elif self._sort == self.SORT_BY_VALUES_DESC:
# pylint: disable=unnecessary-lambda
return sorted(keys, key=lambda x: self._GetHighestValue(x), reverse=True)
+ elif self._sort == self.NO_SORT:
+ return keys
else:
assert 0, 'Unimplemented sort %s' % self._sort