OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 optparse | 5 import optparse |
6 import time | 6 import time |
7 | 7 |
8 from metrics import v8_object_stats | 8 from metrics import v8_object_stats |
9 from telemetry.page import page_measurement | 9 from telemetry.page import page_measurement |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 """Takes a sample and adds a result if enough time has passed.""" | 76 """Takes a sample and adds a result if enough time has passed.""" |
77 self._iterations_elapsed += 1 | 77 self._iterations_elapsed += 1 |
78 if self._iterations_elapsed % int(self.options.perf_stats_interval) == 0: | 78 if self._iterations_elapsed % int(self.options.perf_stats_interval) == 0: |
79 self._SampleStats(tab, results) | 79 self._SampleStats(tab, results) |
80 | 80 |
81 def _SampleStats(self, tab, results): | 81 def _SampleStats(self, tab, results): |
82 """Records information and add it to the results.""" | 82 """Records information and add it to the results.""" |
83 | 83 |
84 def AddPoint(trace_name, units_y, value_y, chart_name=None): | 84 def AddPoint(trace_name, units_y, value_y, chart_name=None): |
85 """Adds one data point to the results object.""" | 85 """Adds one data point to the results object.""" |
86 results.Add(trace_name + '_X', 'iterations', self._iterations_elapsed, | 86 if chart_name: |
87 data_type='unimportant', chart_name=chart_name) | 87 trace_name = '%s.%s' % (chart_name, trace_name) |
88 results.Add(trace_name + '_Y', units_y, value_y, data_type='unimportant', | 88 else: |
89 chart_name=chart_name) | 89 assert '.' not in trace_name, ( |
| 90 'Trace names cannot contain "." with an empty chart_name since this' |
| 91 ' is used to delimit chart_name.trace_name.') |
| 92 results.AddValue(scalar.ScalarValue( |
| 93 results.current_page, trace_name + '_X', 'iterations', |
| 94 self._iterations_elapsed, important=False)) |
| 95 results.AddValue(scalar.ScalarValue( |
| 96 results.current_page, trace_name + '_Y', units_y, value_y, |
| 97 important=False)) |
90 | 98 |
91 # Save the value so that summary stats can be calculated. | 99 # Save the value so that summary stats can be calculated. |
92 if trace_name not in self._y_values: | 100 if trace_name not in self._y_values: |
93 self._y_values[trace_name] = { | 101 self._y_values[trace_name] = { |
94 'units': units_y, | 102 'units': units_y, |
95 'chart_name': chart_name, | 103 'chart_name': chart_name, |
96 'values': [], | 104 'values': [], |
97 } | 105 } |
98 self._y_values[trace_name]['values'].append(value_y) | 106 self._y_values[trace_name]['values'].append(value_y) |
99 | 107 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 important=False)) | 148 important=False)) |
141 | 149 |
142 # Add summary stats which could be monitored for anomalies. | 150 # Add summary stats which could be monitored for anomalies. |
143 for trace_name in self._y_values: | 151 for trace_name in self._y_values: |
144 units = self._y_values[trace_name]['units'] | 152 units = self._y_values[trace_name]['units'] |
145 chart_name = self._y_values[trace_name]['chart_name'] | 153 chart_name = self._y_values[trace_name]['chart_name'] |
146 values = self._y_values[trace_name]['values'] | 154 values = self._y_values[trace_name]['values'] |
147 value_name = '%s.%s_max' % (chart_name, trace_name) | 155 value_name = '%s.%s_max' % (chart_name, trace_name) |
148 results.AddSummaryValue( | 156 results.AddSummaryValue( |
149 scalar.ScalarValue(None, value_name, units, max(values))) | 157 scalar.ScalarValue(None, value_name, units, max(values))) |
OLD | NEW |