|
7 | 7 |
|
8 | 8 | import argparse
|
9 | 9 | from argparse import ArgumentParser
|
| 10 | +import json |
10 | 11 | import sys
|
11 | 12 | import gbench
|
12 | 13 | from gbench import util, report
|
@@ -56,6 +57,12 @@ def create_parser():
|
56 | 57 | help="Do not use colors in the terminal output"
|
57 | 58 | )
|
58 | 59 |
|
| 60 | + parser.add_argument( |
| 61 | + '-d', |
| 62 | + '--dump_to_json', |
| 63 | + dest='dump_to_json', |
| 64 | + help="Additionally, dump benchmark comparison output to this file in JSON format.") |
| 65 | + |
59 | 66 | utest = parser.add_argument_group()
|
60 | 67 | utest.add_argument(
|
61 | 68 | '--no-utest',
|
@@ -244,14 +251,20 @@ def main():
|
244 | 251 | json2 = gbench.report.filter_benchmark(
|
245 | 252 | json2_orig, filter_contender, replacement)
|
246 | 253 |
|
247 |
| - # Diff and output |
248 |
| - output_lines = gbench.report.generate_difference_report( |
249 |
| - json1, json2, args.display_aggregates_only, |
| 254 | + diff_report = gbench.report.get_difference_report( |
| 255 | + json1, json2, args.utest) |
| 256 | + output_lines = gbench.report.print_difference_report( |
| 257 | + diff_report, |
| 258 | + args.display_aggregates_only, |
250 | 259 | args.utest, args.utest_alpha, args.color)
|
251 | 260 | print(description)
|
252 | 261 | for ln in output_lines:
|
253 | 262 | print(ln)
|
254 | 263 |
|
| 264 | + # Optionally, diff and output to JSON |
| 265 | + if args.dump_to_json is not None: |
| 266 | + with open(args.dump_to_json, 'w') as f_json: |
| 267 | + json.dump(diff_report, f_json) |
255 | 268 |
|
256 | 269 | class TestParser(unittest.TestCase):
|
257 | 270 | def setUp(self):
|
|
0 commit comments