Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 # Note: The Perf Dashboard will display these data. Any changes here should | |
| 6 # be updated on Perf Dashboard as well. | |
| 7 | |
| 8 _FAILED_INITIAL_CONFIDENCE_ABORT_REASON = ( | |
| 9 'The metric values for the initial "good" and "bad" revisions ' | |
| 10 'do not represent a clear regression.') | |
| 11 | |
| 12 _DIRECTION_OF_IMPROVEMENT_ABORT_REASON = ( | |
| 13 'The metric values for the initial "good" and "bad" revisions match the ' | |
| 14 'expected direction of improvement. Thus, likely represent an improvement ' | |
| 15 'and not a regression.') | |
| 16 | |
| 17 | |
| 18 def get(api, config, results_without_patch, results_with_patch, labels): | |
|
qyearsley
2016/01/11 22:49:43
Might it be potentially clearer if this module is
chrisphan
2016/01/14 00:53:26
Moved this to perf_try/api for consistency. This
| |
| 19 """Returns the results as a dict.""" | |
| 20 | |
| 21 output_with_patch = results_with_patch.get('output') | |
| 22 output_without_patch = results_without_patch.get('output') | |
| 23 values_with_patch = results_with_patch.get('results').get('values') | |
| 24 values_without_patch = results_without_patch.get('results').get('values') | |
| 25 | |
| 26 cloud_links_without_patch = api.parse_cloud_links(output_without_patch) | |
| 27 cloud_links_with_patch = api.parse_cloud_links(output_with_patch) | |
| 28 | |
| 29 cloud_link = (cloud_links_without_patch['html'][0] | |
| 30 if cloud_links_without_patch['html'] else '') | |
| 31 | |
| 32 results = { | |
| 33 'try_job_id': config.get('try_job_id'), | |
| 34 'status': 'completed', # TODO(chrisphan) Get partial results state. | |
| 35 'buildbot_log_url': '', # TODO(chrisphan) Get this. | |
| 36 'bisect_bot': '', # TODO(chrisphan): Get this. | |
| 37 'command': config.get('command'), | |
| 38 'metric': config.get('metric'), | |
| 39 'cloud_link': cloud_link, | |
| 40 } | |
| 41 | |
| 42 if not values_with_patch or not values_without_patch: | |
| 43 results['warnings'] = ['No values from test with patch, or none ' | |
| 44 'from test without patch.\n Output with patch:\n%s\n\nOutput without ' | |
| 45 'patch:\n%s' % (output_with_patch, output_without_patch)] | |
| 46 return results | |
| 47 | |
| 48 mean_with_patch = api.m.math_utils.mean(values_with_patch) | |
| 49 mean_without_patch = api.m.math_utils.mean(values_without_patch) | |
| 50 | |
| 51 stderr_with_patch = api.m.math_utils.standard_error(values_with_patch) | |
| 52 stderr_without_patch = api.m.math_utils.standard_error( | |
| 53 values_without_patch) | |
| 54 | |
| 55 profiler_with_patch = cloud_links_with_patch['profiler'] | |
| 56 profiler_without_patch = cloud_links_without_patch['profiler'] | |
| 57 | |
| 58 # Calculate the % difference in the means of the 2 runs. | |
| 59 relative_change = None | |
| 60 std_err = None | |
| 61 if mean_with_patch and values_with_patch: | |
| 62 relative_change = api.m.math_utils.relative_change( | |
| 63 mean_without_patch, mean_with_patch) * 100 | |
| 64 std_err = api.m.math_utils.pooled_standard_error( | |
| 65 [values_with_patch, values_without_patch]) | |
| 66 | |
| 67 if relative_change is not None and std_err is not None: | |
| 68 data = [ | |
| 69 ['Revision', 'Mean', 'Std.Error'], | |
| 70 ['Patch', str(mean_with_patch), str(stderr_with_patch)], | |
| 71 ['No Patch', str(mean_without_patch), str(stderr_without_patch)] | |
| 72 ] | |
| 73 results['change'] = relative_change | |
| 74 results['std_err'] = std_err | |
| 75 results['result'] = _pretty_table(data) | |
| 76 | |
| 77 profiler_links = [] | |
| 78 if profiler_with_patch and profiler_without_patch: | |
| 79 for i in xrange(len(profiler_with_patch)): # pragma: no cover | |
| 80 profiler_links.append({ | |
| 81 'title': '%s[%d]' % (labels.get('profiler_link1'), i), | |
| 82 'link': profiler_with_patch[i] | |
| 83 }) | |
| 84 for i in xrange(len(profiler_without_patch)): # pragma: no cover | |
| 85 profiler_links.append({ | |
| 86 'title': '%s[%d]' % (labels.get('profiler_link2'), i), | |
| 87 'link': profiler_without_patch[i] | |
| 88 }) | |
| 89 results['profiler_links'] = profiler_links | |
| 90 | |
| 91 return results | |
| 92 | |
| 93 def _pretty_table(data): | |
| 94 results = [] | |
| 95 for row in data: | |
| 96 results.append('%-15s' * len(row) % tuple(row)) | |
| 97 return '\n'.join(results) | |
| OLD | NEW |