Skip to content

Commit

Permalink
Fix malformed sizes data
Browse files Browse the repository at this point in the history
Fixes the sizes.py script producing malformed data that couldn't be
converted to histograms. The conversion script expects metric dicts
that contain story dicts, but sizes was essentially only producing
metric dicts.

This pulls out the "identifier" value to be the story name since that
seems to be what the perf dashboard is doing automatically when
uploading in the old format.

Bug: 906685
Change-Id: Ie06f2ff477e3346059473863138478c261712772
Reviewed-on: https://chromium-review.googlesource.com/c/1377195
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616807}
  • Loading branch information
bsheedy authored and Commit Bot committed Dec 14, 2018
1 parent 169558a commit c823058
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions infra/scripts/legacy/scripts/slave/chromium/sizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,24 @@ def main_win(options, args, results_collector):
return 0


def format_for_histograms_conversion(data):
# We need to do two things to the provided data to make it compatible with the
# conversion script:
# 1. Add a top-level "benchmark_name" key.
# 2. Pull out the "identifier" value to be the story name.
formatted_data = {}
for metric, metric_data in data.iteritems():
story = metric_data['identifier']
formatted_data[metric] = {
story: metric_data.copy()
}
del formatted_data[metric][story]['identifier']
return {
'benchmark_name': 'sizes',
'charts': formatted_data
}


def main():
if sys.platform in ('win32', 'cygwin'):
default_platform = 'win'
Expand Down Expand Up @@ -467,13 +485,10 @@ def main():

if options.output_dir:
histogram_path = os.path.join(options.output_dir, 'perf_results.json')
# We need to add a bit more data to the results, otherwise the conversion
# fails due to the provided data being malformed.
updated_results = {
'format_version': '1.0',
'benchmark_name': 'sizes',
'charts': results_collector.results,
}
# We need to add a bit more data to the results and rearrange some things,
# otherwise the conversion fails due to the provided data being malformed.
updated_results = format_for_histograms_conversion(
results_collector.results)
with open(histogram_path, 'w') as f:
json.dump(updated_results, f)
histogram_result = convert_chart_json.ConvertChartJson(histogram_path)
Expand Down

0 comments on commit c823058

Please sign in to comment.