Unverified Commit 949f5bb1 by Jusufadis Bakamovic Committed by GitHub

Add support for JSON dumps of benchmark diff reports. (#1042). Fixes #737.

NOTE: This is a fresh-start of #738 pull-request which I messed up by re-editing the commiter email which I forgot to modify before pushing. Sorry for the inconvenience. This PR brings proposed solution for functionality described in #737 Fixes #737.
parent 7efada2d
...@@ -7,6 +7,7 @@ compare.py - versatile benchmark output compare tool ...@@ -7,6 +7,7 @@ compare.py - versatile benchmark output compare tool
import argparse import argparse
from argparse import ArgumentParser from argparse import ArgumentParser
import json
import sys import sys
import gbench import gbench
from gbench import util, report from gbench import util, report
...@@ -56,6 +57,12 @@ def create_parser(): ...@@ -56,6 +57,12 @@ def create_parser():
help="Do not use colors in the terminal output" help="Do not use colors in the terminal output"
) )
parser.add_argument(
'-d',
'--dump_to_json',
dest='dump_to_json',
help="Additionally, dump benchmark comparison output to this file in JSON format.")
utest = parser.add_argument_group() utest = parser.add_argument_group()
utest.add_argument( utest.add_argument(
'--no-utest', '--no-utest',
...@@ -244,14 +251,20 @@ def main(): ...@@ -244,14 +251,20 @@ def main():
json2 = gbench.report.filter_benchmark( json2 = gbench.report.filter_benchmark(
json2_orig, filter_contender, replacement) json2_orig, filter_contender, replacement)
# Diff and output diff_report = gbench.report.get_difference_report(
output_lines = gbench.report.generate_difference_report( json1, json2, args.utest)
json1, json2, args.display_aggregates_only, output_lines = gbench.report.print_difference_report(
diff_report,
args.display_aggregates_only,
args.utest, args.utest_alpha, args.color) args.utest, args.utest_alpha, args.color)
print(description) print(description)
for ln in output_lines: for ln in output_lines:
print(ln) print(ln)
# Optionally, diff and output to JSON
if args.dump_to_json is not None:
with open(args.dump_to_json, 'w') as f_json:
json.dump(diff_report, f_json)
class TestParser(unittest.TestCase): class TestParser(unittest.TestCase):
def setUp(self): def setUp(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment