aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorFelix Duvallet <felixduvallet@users.noreply.github.com>2017-05-02 17:19:35 +0200
committerDominic Hamon <dominichamon@users.noreply.github.com>2017-05-02 08:19:35 -0700
commitfeb69ae7102e6bdcb5736cd7c1669969217d45c0 (patch)
tree93a503dc3beeb71859bfe1adebc584eaf79d4ac5 /tools
parent3336ea00d892fc312715c3a00d33a9568261e86a (diff)
downloadgoogle-benchmark-feb69ae7102e6bdcb5736cd7c1669969217d45c0.tar.gz
Ensure all the necessary keys are present before parsing JSON data (#380)
This prevents errors when additional non-timing data are present in the JSON that is loaded, for example when complexity data has been computed (see #379).
Diffstat (limited to 'tools')
-rw-r--r--tools/gbench/report.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/gbench/report.py b/tools/gbench/report.py
index 8f1b0fa..015d33d 100644
--- a/tools/gbench/report.py
+++ b/tools/gbench/report.py
@@ -80,7 +80,9 @@ def generate_difference_report(json1, json2, use_color=True):
first_line = "{:<{}s} Time CPU Old New".format(
'Benchmark', first_col_width)
output_strs = [first_line, '-' * len(first_line)]
- for bn in json1['benchmarks']:
+
+ gen = (bn for bn in json1['benchmarks'] if 'real_time' in bn and 'cpu_time' in bn)
+ for bn in gen:
other_bench = find_test(bn['name'])
if not other_bench:
continue