| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from telemetry import perf_tests_helper | 5 from telemetry import perf_tests_helper |
| 6 from telemetry import value as value_module | 6 from telemetry import value as value_module |
| 7 from telemetry.value import summary as summary_module | 7 from telemetry.value import summary as summary_module |
| 8 from telemetry.results import page_measurement_results | 8 from telemetry.results import page_measurement_results |
| 9 | 9 |
| 10 | 10 |
| 11 class BuildbotPageMeasurementResults( | 11 class BuildbotPageMeasurementResults( |
| 12 page_measurement_results.PageMeasurementResults): | 12 page_measurement_results.PageMeasurementResults): |
| 13 def __init__(self, output_stream, trace_tag=''): | 13 def __init__(self, output_stream, trace_tag=''): |
| 14 super(BuildbotPageMeasurementResults, self).__init__(output_stream) | 14 super(BuildbotPageMeasurementResults, self).__init__(output_stream) |
| 15 self._trace_tag = trace_tag | 15 self._trace_tag = trace_tag |
| 16 | 16 |
| 17 def _PrintPerfResult(self, measurement, trace, v, units, | 17 def _PrintPerfResult(self, measurement, trace, v, units, |
| 18 result_type='default'): | 18 result_type='default'): |
| 19 output = perf_tests_helper.PrintPerfResult( | 19 output = perf_tests_helper.PrintPerfResult( |
| 20 measurement, trace, v, units, result_type, print_to_stdout=False) | 20 measurement, trace, v, units, result_type, print_to_stdout=False) |
| 21 self._output_stream.write(output + '\n') | 21 self._output_stream.write(output + '\n') |
| 22 self._output_stream.flush() | 22 self._output_stream.flush() |
| 23 | 23 |
| 24 @property | 24 @property |
| 25 def had_errors_or_failures(self): | 25 def had_failures(self): |
| 26 return self.errors or self.failures | 26 return len(self.failures) > 0 |
| 27 | 27 |
| 28 def PrintSummary(self): | 28 def PrintSummary(self): |
| 29 """Print summary data in a format expected by buildbot for perf dashboards. | 29 """Print summary data in a format expected by buildbot for perf dashboards. |
| 30 | 30 |
| 31 If any failed pages exist, only output individual page results, and do | 31 If any failed pages exist, only output individual page results, and do |
| 32 not output any average data. | 32 not output any average data. |
| 33 """ | 33 """ |
| 34 # Print out the list of unique pages. | 34 # Print out the list of unique pages. |
| 35 perf_tests_helper.PrintPages( | 35 perf_tests_helper.PrintPages( |
| 36 [page.display_name for page in self.pages_that_succeeded]) | 36 [page.display_name for page in self.pages_that_succeeded]) |
| 37 summary = summary_module.Summary(self.all_page_specific_values, | 37 summary = summary_module.Summary(self.all_page_specific_values, |
| 38 self.had_errors_or_failures) | 38 self.had_failures) |
| 39 for value in summary.interleaved_computed_per_page_values_and_summaries: | 39 for value in summary.interleaved_computed_per_page_values_and_summaries: |
| 40 if value.page: | 40 if value.page: |
| 41 self._PrintComputedPerPageValue(value) | 41 self._PrintComputedPerPageValue(value) |
| 42 else: | 42 else: |
| 43 self._PrintComputedSummaryValue(value) | 43 self._PrintComputedSummaryValue(value) |
| 44 self._PrintOverallResults() | 44 self._PrintOverallResults() |
| 45 | 45 |
| 46 def _PrintComputedPerPageValue(self, value): | 46 def _PrintComputedPerPageValue(self, value): |
| 47 # We dont print per-page-values when there is a trace tag. | 47 # We dont print per-page-values when there is a trace tag. |
| 48 if self._trace_tag: | 48 if self._trace_tag: |
| 49 return | 49 return |
| 50 | 50 |
| 51 # Actually print the result. | 51 # Actually print the result. |
| 52 buildbot_value = value.GetBuildbotValue() | 52 buildbot_value = value.GetBuildbotValue() |
| 53 buildbot_data_type = value.GetBuildbotDataType( | 53 buildbot_data_type = value.GetBuildbotDataType( |
| 54 output_context=value_module.PER_PAGE_RESULT_OUTPUT_CONTEXT) | 54 output_context=value_module.PER_PAGE_RESULT_OUTPUT_CONTEXT) |
| 55 buildbot_measurement_name, buildbot_trace_name = ( | 55 buildbot_measurement_name, buildbot_trace_name = ( |
| 56 value.GetBuildbotMeasurementAndTraceNameForPerPageResult()) | 56 value.GetBuildbotMeasurementAndTraceNameForPerPageResult()) |
| 57 self._PrintPerfResult(buildbot_measurement_name, | 57 self._PrintPerfResult(buildbot_measurement_name, |
| 58 buildbot_trace_name, | 58 buildbot_trace_name, |
| 59 buildbot_value, value.units, buildbot_data_type) | 59 buildbot_value, value.units, buildbot_data_type) |
| 60 | 60 |
| 61 def _PrintComputedSummaryValue(self, value): | 61 def _PrintComputedSummaryValue(self, value): |
| 62 # If there were any page errors, we typically will print nothing. | 62 # If there were any page errors, we typically will print nothing. |
| 63 # | 63 # |
| 64 # Note: this branch is structured less-densely to improve legibility. | 64 # Note: this branch is structured less-densely to improve legibility. |
| 65 if self.had_errors_or_failures: | 65 if self.had_failures: |
| 66 return | 66 return |
| 67 | 67 |
| 68 buildbot_value = value.GetBuildbotValue() | 68 buildbot_value = value.GetBuildbotValue() |
| 69 buildbot_data_type = value.GetBuildbotDataType( | 69 buildbot_data_type = value.GetBuildbotDataType( |
| 70 output_context=value_module.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT) | 70 output_context=value_module.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT) |
| 71 buildbot_measurement_name, buildbot_trace_name = ( | 71 buildbot_measurement_name, buildbot_trace_name = ( |
| 72 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( | 72 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( |
| 73 self._trace_tag)) | 73 self._trace_tag)) |
| 74 | 74 |
| 75 self._PrintPerfResult(buildbot_measurement_name, | 75 self._PrintPerfResult(buildbot_measurement_name, |
| 76 buildbot_trace_name, | 76 buildbot_trace_name, |
| 77 buildbot_value, value.units, buildbot_data_type) | 77 buildbot_value, value.units, buildbot_data_type) |
| 78 | 78 |
| 79 def _PrintOverallResults(self): | 79 def _PrintOverallResults(self): |
| 80 # If there were no failed pages, output the overall results (results not | 80 # If there were no failed pages, output the overall results (results not |
| 81 # associated with a page). | 81 # associated with a page). |
| 82 if not self.had_errors_or_failures: | 82 if not self.had_failures: |
| 83 for value in self._all_summary_values: | 83 for value in self._all_summary_values: |
| 84 buildbot_value = value.GetBuildbotValue() | 84 buildbot_value = value.GetBuildbotValue() |
| 85 buildbot_data_type = value.GetBuildbotDataType( | 85 buildbot_data_type = value.GetBuildbotDataType( |
| 86 output_context=value_module.SUMMARY_RESULT_OUTPUT_CONTEXT) | 86 output_context=value_module.SUMMARY_RESULT_OUTPUT_CONTEXT) |
| 87 buildbot_measurement_name, buildbot_trace_name = ( | 87 buildbot_measurement_name, buildbot_trace_name = ( |
| 88 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( | 88 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( |
| 89 self._trace_tag)) | 89 self._trace_tag)) |
| 90 self._PrintPerfResult( | 90 self._PrintPerfResult( |
| 91 buildbot_measurement_name, | 91 buildbot_measurement_name, |
| 92 buildbot_trace_name, | 92 buildbot_trace_name, |
| 93 buildbot_value, | 93 buildbot_value, |
| 94 value.units, | 94 value.units, |
| 95 buildbot_data_type) | 95 buildbot_data_type) |
| 96 | 96 |
| 97 | 97 |
| 98 # Print the number of failed and errored pages. | 98 # Print the number of failed and errored pages. |
| 99 self._PrintPerfResult('telemetry_page_measurement_results', 'num_failed', | 99 self._PrintPerfResult('telemetry_page_measurement_results', 'num_failed', |
| 100 [len(self.failures)], 'count', 'unimportant') | 100 [len(self.failures)], 'count', 'unimportant') |
| 101 |
| 102 # TODO(chrishenry): Remove this in a separate patch to reduce the risk |
| 103 # of rolling back due to buildbot breakage. |
| 104 # Also fix src/tools/bisect-perf-regression_test.py when this is |
| 105 # removed. |
| 101 self._PrintPerfResult('telemetry_page_measurement_results', 'num_errored', | 106 self._PrintPerfResult('telemetry_page_measurement_results', 'num_errored', |
| 102 [len(self.errors)], 'count', 'unimportant') | 107 [0], 'count', 'unimportant') |
| 103 | 108 |
| 104 super(BuildbotPageMeasurementResults, self).PrintSummary() | 109 super(BuildbotPageMeasurementResults, self).PrintSummary() |
| OLD | NEW |