aboutsummaryrefslogtreecommitdiff
path: root/crosperf/generate_report.py
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-27 22:54:29 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-27 22:54:29 +0000
commiteef05f06e8d4f7d4b4df22a398fba3af34fd27a6 (patch)
tree2ead2b1ce7a70c34fe8be06e45a40d9e2f6358d0 /crosperf/generate_report.py
parent65f2caf1f91f0198174d7677816a352299fce130 (diff)
parentb6ed922ff73f31b13749595f02b62a849a904dcc (diff)
downloadtoolchain-utils-eef05f06e8d4f7d4b4df22a398fba3af34fd27a6.tar.gz
Merging 11 commit(s) from Chromium's toolchain-utils am: 554bca16f8 am: b6ed922ff7
Change-Id: Id08acb74cf1ff2e847d11407f5218a6893d42e50
Diffstat (limited to 'crosperf/generate_report.py')
-rwxr-xr-xcrosperf/generate_report.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/crosperf/generate_report.py b/crosperf/generate_report.py
index fd7a2cf7..cea95a2e 100755
--- a/crosperf/generate_report.py
+++ b/crosperf/generate_report.py
@@ -1,8 +1,9 @@
#!/usr/bin/env python2
-#
+# -*- coding: utf-8 -*-
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
"""Given a specially-formatted JSON object, generates results report(s).
The JSON object should look like:
@@ -67,8 +68,7 @@ def CountBenchmarks(benchmark_runs):
def _MaxLen(results):
return 0 if not results else max(len(r) for r in results)
- return [(name, _MaxLen(results))
- for name, results in benchmark_runs.iteritems()]
+ return [(name, _MaxLen(results)) for name, results in benchmark_runs.items()]
def CutResultsInPlace(results, max_keys=50, complain_on_update=True):
@@ -130,9 +130,14 @@ def CutResultsInPlace(results, max_keys=50, complain_on_update=True):
def _ConvertToASCII(obj):
"""Convert an object loaded from JSON to ASCII; JSON gives us unicode."""
+ # In python 3, we can directly return the unicode loaded from json.
+ if sys.version_info.major == 3:
+ return obj
+ # TODO(zhizhouy): Drop the following code once migrated to python 3.
# Using something like `object_hook` is insufficient, since it only fires on
# actual JSON objects. `encoding` fails, too, since the default decoder always
# uses unicode() to decode strings.
+ # pylint: disable=unicode-builtin
if isinstance(obj, unicode):
return str(obj)
if isinstance(obj, dict):