Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: tools/telemetry/telemetry/results/buildbot_output_formatter.py

Issue 421503005: Move Html and BuildbotPageMeasurementResults to {Html,Buildbot}OutputFormatter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/results/buildbot_output_formatter_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 output_formatter
9 9
10 10
11 class BuildbotPageMeasurementResults( 11 class BuildbotOutputFormatter(output_formatter.OutputFormatter):
12 page_measurement_results.PageMeasurementResults):
13 def __init__(self, output_stream, trace_tag=''): 12 def __init__(self, output_stream, trace_tag=''):
14 super(BuildbotPageMeasurementResults, self).__init__(output_stream) 13 super(BuildbotOutputFormatter, self).__init__(output_stream)
15 self._trace_tag = trace_tag 14 self._trace_tag = trace_tag
16 15
17 def _PrintPerfResult(self, measurement, trace, v, units, 16 def _PrintPerfResult(self, measurement, trace, v, units,
18 result_type='default'): 17 result_type='default'):
19 output = perf_tests_helper.PrintPerfResult( 18 output = perf_tests_helper.PrintPerfResult(
20 measurement, trace, v, units, result_type, print_to_stdout=False) 19 measurement, trace, v, units, result_type, print_to_stdout=False)
21 self._output_stream.write(output + '\n') 20 self.output_stream.write(output + '\n')
22 self._output_stream.flush() 21 self.output_stream.flush()
23 22
24 @property 23 def Format(self, page_test_results):
25 def had_failures(self):
26 return len(self.failures) > 0
27
28 def PrintSummary(self):
29 """Print summary data in a format expected by buildbot for perf dashboards. 24 """Print summary data in a format expected by buildbot for perf dashboards.
30 25
31 If any failed pages exist, only output individual page results, and do 26 If any failed pages exist, only output individual page results, and do
32 not output any average data. 27 not output any average data.
33 """ 28 """
29 had_failures = len(page_test_results.failures) > 0
30
34 # Print out the list of unique pages. 31 # Print out the list of unique pages.
35 perf_tests_helper.PrintPages( 32 perf_tests_helper.PrintPages(
36 [page.display_name for page in self.pages_that_succeeded]) 33 [page.display_name for page in page_test_results.pages_that_succeeded])
37 summary = summary_module.Summary(self.all_page_specific_values, 34 summary = summary_module.Summary(page_test_results.all_page_specific_values,
38 self.had_failures) 35 had_failures)
39 for value in summary.interleaved_computed_per_page_values_and_summaries: 36 for value in summary.interleaved_computed_per_page_values_and_summaries:
40 if value.page: 37 if value.page:
41 self._PrintComputedPerPageValue(value) 38 self._PrintComputedPerPageValue(value)
42 else: 39 else:
43 self._PrintComputedSummaryValue(value) 40 self._PrintComputedSummaryValue(value, had_failures)
44 self._PrintOverallResults() 41 self._PrintOverallResults(page_test_results)
45 42
46 def _PrintComputedPerPageValue(self, value): 43 def _PrintComputedPerPageValue(self, value):
47 # We dont print per-page-values when there is a trace tag. 44 # We dont print per-page-values when there is a trace tag.
48 if self._trace_tag: 45 if self._trace_tag:
49 return 46 return
50 47
51 # Actually print the result. 48 # Actually print the result.
52 buildbot_value = value.GetBuildbotValue() 49 buildbot_value = value.GetBuildbotValue()
53 buildbot_data_type = value.GetBuildbotDataType( 50 buildbot_data_type = value.GetBuildbotDataType(
54 output_context=value_module.PER_PAGE_RESULT_OUTPUT_CONTEXT) 51 output_context=value_module.PER_PAGE_RESULT_OUTPUT_CONTEXT)
55 if buildbot_value is None or buildbot_data_type is None: 52 if buildbot_value is None or buildbot_data_type is None:
56 return 53 return
57 54
58 buildbot_measurement_name, buildbot_trace_name = ( 55 buildbot_measurement_name, buildbot_trace_name = (
59 value.GetBuildbotMeasurementAndTraceNameForPerPageResult()) 56 value.GetBuildbotMeasurementAndTraceNameForPerPageResult())
60 self._PrintPerfResult(buildbot_measurement_name, 57 self._PrintPerfResult(buildbot_measurement_name,
61 buildbot_trace_name, 58 buildbot_trace_name,
62 buildbot_value, value.units, buildbot_data_type) 59 buildbot_value, value.units, buildbot_data_type)
63 60
64 def _PrintComputedSummaryValue(self, value): 61 def _PrintComputedSummaryValue(self, value, had_failures):
65 # If there were any page errors, we typically will print nothing. 62 # If there were any page errors, we typically will print nothing.
66 # 63 #
67 # Note: this branch is structured less-densely to improve legibility. 64 # Note: this branch is structured less-densely to improve legibility.
68 if self.had_failures: 65 if had_failures:
69 return 66 return
70 67
71 buildbot_value = value.GetBuildbotValue() 68 buildbot_value = value.GetBuildbotValue()
72 buildbot_data_type = value.GetBuildbotDataType( 69 buildbot_data_type = value.GetBuildbotDataType(
73 output_context=value_module.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT) 70 output_context=value_module.COMPUTED_PER_PAGE_SUMMARY_OUTPUT_CONTEXT)
74 if buildbot_value is None or buildbot_data_type is None: 71 if buildbot_value is None or buildbot_data_type is None:
75 return 72 return
76 73
77 buildbot_measurement_name, buildbot_trace_name = ( 74 buildbot_measurement_name, buildbot_trace_name = (
78 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( 75 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult(
79 self._trace_tag)) 76 self._trace_tag))
80 self._PrintPerfResult(buildbot_measurement_name, 77 self._PrintPerfResult(buildbot_measurement_name,
81 buildbot_trace_name, 78 buildbot_trace_name,
82 buildbot_value, value.units, buildbot_data_type) 79 buildbot_value, value.units, buildbot_data_type)
83 80
84 def _PrintOverallResults(self): 81 def _PrintOverallResults(self, page_test_results):
85 # If there were no failed pages, output the overall results (results not 82 # If there were no failed pages, output the overall results (results not
86 # associated with a page). 83 # associated with a page).
87 if not self.had_failures: 84 had_failures = len(page_test_results.failures) > 0
88 for value in self.all_summary_values: 85 if not had_failures:
86 for value in page_test_results.all_summary_values:
89 buildbot_value = value.GetBuildbotValue() 87 buildbot_value = value.GetBuildbotValue()
90 buildbot_data_type = value.GetBuildbotDataType( 88 buildbot_data_type = value.GetBuildbotDataType(
91 output_context=value_module.SUMMARY_RESULT_OUTPUT_CONTEXT) 89 output_context=value_module.SUMMARY_RESULT_OUTPUT_CONTEXT)
92 buildbot_measurement_name, buildbot_trace_name = ( 90 buildbot_measurement_name, buildbot_trace_name = (
93 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult( 91 value.GetBuildbotMeasurementAndTraceNameForComputedSummaryResult(
94 self._trace_tag)) 92 self._trace_tag))
95 self._PrintPerfResult( 93 self._PrintPerfResult(
96 buildbot_measurement_name, 94 buildbot_measurement_name,
97 buildbot_trace_name, 95 buildbot_trace_name,
98 buildbot_value, 96 buildbot_value,
99 value.units, 97 value.units,
100 buildbot_data_type) 98 buildbot_data_type)
101 99
102
103 # Print the number of failed and errored pages. 100 # Print the number of failed and errored pages.
104 self._PrintPerfResult('telemetry_page_measurement_results', 'num_failed', 101 self._PrintPerfResult('telemetry_page_measurement_results', 'num_failed',
105 [len(self.failures)], 'count', 'unimportant') 102 [len(page_test_results.failures)], 'count',
103 'unimportant')
106 104
107 # TODO(chrishenry): Remove this in a separate patch to reduce the risk 105 # TODO(chrishenry): Remove this in a separate patch to reduce the risk
108 # of rolling back due to buildbot breakage. 106 # of rolling back due to buildbot breakage.
109 # Also fix src/tools/bisect-perf-regression_test.py when this is 107 # Also fix src/tools/bisect-perf-regression_test.py when this is
110 # removed. 108 # removed.
111 self._PrintPerfResult('telemetry_page_measurement_results', 'num_errored', 109 self._PrintPerfResult('telemetry_page_measurement_results', 'num_errored',
112 [0], 'count', 'unimportant') 110 [0], 'count', 'unimportant')
113
114 super(BuildbotPageMeasurementResults, self).PrintSummary()
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/results/buildbot_output_formatter_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698