| 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 import datetime | 5 import datetime |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 | 10 |
| 11 from catapult_base import cloud_storage | 11 from catapult_base import cloud_storage |
| 12 from telemetry.core import util | 12 from telemetry.core import util |
| 13 from telemetry.internal.results import chart_json_output_formatter | 13 from telemetry.internal.results import chart_json_output_formatter |
| 14 from telemetry.internal.results import output_formatter | 14 from telemetry.internal.results import output_formatter |
| 15 from telemetry import value as value_module | 15 from telemetry import value as value_module |
| 16 from telemetry.value import list_of_scalar_values |
| 16 | 17 |
| 17 | 18 |
| 18 _TEMPLATE_HTML_PATH = os.path.join( | 19 _TEMPLATE_HTML_PATH = os.path.join( |
| 19 util.GetTelemetryDir(), 'support', 'html_output', 'results-template.html') | 20 util.GetTelemetryDir(), 'support', 'html_output', 'results-template.html') |
| 20 _JS_PLUGINS = [os.path.join('flot', 'jquery.flot.min.js'), | 21 _JS_PLUGINS = [os.path.join('flot', 'jquery.flot.min.js'), |
| 21 os.path.join('WebKit', 'PerformanceTests', 'resources', | 22 os.path.join('WebKit', 'PerformanceTests', 'resources', |
| 22 'jquery.tablesorter.min.js'), | 23 'jquery.tablesorter.min.js'), |
| 23 os.path.join('WebKit', 'PerformanceTests', 'resources', | 24 os.path.join('WebKit', 'PerformanceTests', 'resources', |
| 24 'statistics.js')] | 25 'statistics.js')] |
| 25 _UNIT_JSON = os.path.join( | 26 _UNIT_JSON = os.path.join( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 logging.warn('Failed to extract previous results from HTML output') | 86 logging.warn('Failed to extract previous results from HTML output') |
| 86 return [] | 87 return [] |
| 87 return json.loads(m.group(1))[:512] | 88 return json.loads(m.group(1))[:512] |
| 88 | 89 |
| 89 def _SaveResults(self, results): | 90 def _SaveResults(self, results): |
| 90 self._output_stream.seek(0) | 91 self._output_stream.seek(0) |
| 91 self._output_stream.write(results) | 92 self._output_stream.write(results) |
| 92 self._output_stream.truncate() | 93 self._output_stream.truncate() |
| 93 | 94 |
| 94 def _PrintPerfResult(self, measurement, trace, values, units, | 95 def _PrintPerfResult(self, measurement, trace, values, units, |
| 95 result_type='default'): | 96 result_type='default', std=None): |
| 96 metric_name = measurement | 97 metric_name = measurement |
| 97 if trace != measurement: | 98 if trace != measurement: |
| 98 metric_name += '.' + trace | 99 metric_name += '.' + trace |
| 99 self._result['tests'].setdefault(self._test_name, {}) | 100 self._result['tests'].setdefault(self._test_name, {}) |
| 100 self._result['tests'][self._test_name].setdefault('metrics', {}) | 101 self._result['tests'][self._test_name].setdefault('metrics', {}) |
| 101 self._result['tests'][self._test_name]['metrics'][metric_name] = { | 102 metric_data = { |
| 102 'current': values, | 103 'current': values, |
| 103 'units': units, | 104 'units': units, |
| 104 'important': result_type == 'default' | 105 'important': result_type == 'default' |
| 105 } | 106 } |
| 107 if std is not None: |
| 108 metric_data['std'] = std |
| 109 self._result['tests'][self._test_name]['metrics'][metric_name] = metric_data |
| 106 | 110 |
| 107 def _TranslateChartJson(self, chart_json_dict): | 111 def _TranslateChartJson(self, chart_json_dict): |
| 108 dummy_dict = dict() | 112 dummy_dict = dict() |
| 109 | 113 |
| 110 for chart_name, traces in chart_json_dict['charts'].iteritems(): | 114 for chart_name, traces in chart_json_dict['charts'].iteritems(): |
| 111 for trace_name, value_dict in traces.iteritems(): | 115 for trace_name, value_dict in traces.iteritems(): |
| 112 # TODO(eakuefner): refactor summarization so we don't have to jump | 116 # TODO(eakuefner): refactor summarization so we don't have to jump |
| 113 # through hoops like this. | 117 # through hoops like this. |
| 114 if 'page_id' in value_dict: | 118 if 'page_id' in value_dict: |
| 115 del value_dict['page_id'] | 119 del value_dict['page_id'] |
| 116 result_type = 'nondefault' | 120 result_type = 'nondefault' |
| 117 else: | 121 else: |
| 118 result_type = 'default' | 122 result_type = 'default' |
| 119 | 123 |
| 120 # Note: we explicitly ignore TraceValues because Buildbot did. | 124 # Note: we explicitly ignore TraceValues because Buildbot did. |
| 121 if value_dict['type'] == 'trace': | 125 if value_dict['type'] == 'trace': |
| 122 continue | 126 continue |
| 123 value = value_module.Value.FromDict(value_dict, dummy_dict) | 127 value = value_module.Value.FromDict(value_dict, dummy_dict) |
| 124 | 128 |
| 125 perf_value = value.GetBuildbotValue() | 129 perf_value = value.GetBuildbotValue() |
| 126 | 130 |
| 127 if trace_name == 'summary': | 131 if trace_name == 'summary': |
| 128 trace_name = chart_name | 132 trace_name = chart_name |
| 129 | 133 |
| 134 std = None |
| 135 if isinstance(value, list_of_scalar_values.ListOfScalarValues): |
| 136 std = value.std |
| 137 |
| 130 self._PrintPerfResult(chart_name, trace_name, perf_value, | 138 self._PrintPerfResult(chart_name, trace_name, perf_value, |
| 131 value.units, result_type) | 139 value.units, result_type, std) |
| 132 | 140 |
| 133 @property | 141 @property |
| 134 def _test_name(self): | 142 def _test_name(self): |
| 135 return self._metadata.name | 143 return self._metadata.name |
| 136 | 144 |
| 137 def GetResults(self): | 145 def GetResults(self): |
| 138 return self._result | 146 return self._result |
| 139 | 147 |
| 140 def GetCombinedResults(self): | 148 def GetCombinedResults(self): |
| 141 all_results = list(self._existing_results) | 149 all_results = list(self._existing_results) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 167 print | 175 print |
| 168 print ('View online at ' | 176 print ('View online at ' |
| 169 'http://storage.googleapis.com/chromium-telemetry/%s' | 177 'http://storage.googleapis.com/chromium-telemetry/%s' |
| 170 % file_name) | 178 % file_name) |
| 171 except cloud_storage.PermissionError as e: | 179 except cloud_storage.PermissionError as e: |
| 172 logging.error('Cannot upload profiling files to cloud storage due to ' | 180 logging.error('Cannot upload profiling files to cloud storage due to ' |
| 173 ' permission error: %s' % e.message) | 181 ' permission error: %s' % e.message) |
| 174 print | 182 print |
| 175 print 'View result at file://%s' % os.path.abspath( | 183 print 'View result at file://%s' % os.path.abspath( |
| 176 self._output_stream.name) | 184 self._output_stream.name) |
| OLD | NEW |