diff options
Diffstat (limited to 'libcxx/utils')
-rwxr-xr-x | libcxx/utils/compare-benchmarks | 2 | ||||
-rwxr-xr-x | libcxx/utils/visualize-historical | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libcxx/utils/compare-benchmarks b/libcxx/utils/compare-benchmarks index d165c73..b5bd880 100755 --- a/libcxx/utils/compare-benchmarks +++ b/libcxx/utils/compare-benchmarks @@ -72,7 +72,7 @@ def plain_text_comparison(data, metric, baseline_name=None, candidate_name=None) geomean_0 = statistics.geometric_mean(data[f'{metric}_0'].dropna()) geomean_1 = statistics.geometric_mean(data[f'{metric}_1'].dropna()) geomean_row = ['Geomean', geomean_0, geomean_1, (geomean_1 - geomean_0), (geomean_1 - geomean_0) / geomean_0] - table.loc[table.index.max()] = geomean_row + table.loc[table.index.max() + 1] = geomean_row return tabulate.tabulate(table.set_index('benchmark'), headers=headers, floatfmt=fmt, numalign='right') diff --git a/libcxx/utils/visualize-historical b/libcxx/utils/visualize-historical index 114c7e8..0a94b15 100755 --- a/libcxx/utils/visualize-historical +++ b/libcxx/utils/visualize-historical @@ -112,7 +112,7 @@ def truncate_lines(string, n, marker=None): assert len(truncated) <= n, "broken post-condition" return '\n'.join(truncated) -def create_plot(data, metric, subtitle=None): +def create_plot(data, metric, trendline=None, subtitle=None): """ Create a plot object showing the evolution of each benchmark throughout the given commits for the given metric. @@ -126,7 +126,7 @@ def create_plot(data, metric, subtitle=None): symbol='benchmark', color='benchmark', hover_name=[hover_info[c] for c in data['commit']], - trendline="lowess") + trendline=trendline) return figure def directory_path(string): @@ -221,6 +221,10 @@ def main(argv): parser.add_argument('--open', action='store_true', help='Whether to automatically open the generated HTML file when finished. If no output file is provided, ' 'the resulting benchmark is opened automatically by default.') + parser.add_argument('--trendline', type=str, required=False, default=None, choices=('ols', 'lowess', 'expanding'), + help='Optional trendline to add on each series in the chart. See the documentation in ' + 'https://plotly.com/python-api-reference/generated/plotly.express.trendline_functions.html ' + 'details on each option.') args = parser.parse_args(argv) # Extract benchmark data from the directory. @@ -250,9 +254,11 @@ def main(argv): if args.filter is not None: keeplist = [b for b in data['benchmark'] if re.search(args.filter, b) is not None] data = data[data['benchmark'].isin(keeplist)] + if len(data) == 0: + raise RuntimeError(f'Filter "{args.filter}" resulted in empty data set -- nothing to plot') # Plot the data for all the required benchmarks. - figure = create_plot(data, args.metric, subtitle=args.subtitle) + figure = create_plot(data, args.metric, trendline=args.trendline, subtitle=args.subtitle) do_open = args.output is None or args.open output = args.output if args.output is not None else tempfile.NamedTemporaryFile(suffix='.html').name plotly.io.write_html(figure, file=output, auto_open=do_open) |