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 import collections | 4 import collections |
5 import logging | 5 import logging |
6 from collections import defaultdict | 6 from collections import defaultdict |
7 | 7 |
8 from tracing.metrics import metric_runner | 8 from tracing.metrics import metric_runner |
9 | 9 |
10 from telemetry.timeline import chrome_trace_category_filter | 10 from telemetry.timeline import chrome_trace_category_filter |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 if self._tbm_options.config.enable_chrome_trace: | 277 if self._tbm_options.config.enable_chrome_trace: |
278 # Always enable 'blink.console' category for: | 278 # Always enable 'blink.console' category for: |
279 # 1) Backward compat of chrome clock sync (crbug.com/646925) | 279 # 1) Backward compat of chrome clock sync (crbug.com/646925) |
280 # 2) Allows users to add trace event through javascript. | 280 # 2) Allows users to add trace event through javascript. |
281 # Note that blink.console is extremely low-overhead, so this doesn't | 281 # Note that blink.console is extremely low-overhead, so this doesn't |
282 # affect the tracing overhead budget much. | 282 # affect the tracing overhead budget much. |
283 chrome_config = self._tbm_options.config.chrome_trace_config | 283 chrome_config = self._tbm_options.config.chrome_trace_config |
284 chrome_config.category_filter.AddIncludedCategory('blink.console') | 284 chrome_config.category_filter.AddIncludedCategory('blink.console') |
285 platform.tracing_controller.StartTracing(self._tbm_options.config) | 285 platform.tracing_controller.StartTracing(self._tbm_options.config) |
286 | 286 |
| 287 def GetTimelineBasedMetrics(self): |
| 288 return self._tbm_options.GetTimelineBasedMetrics() |
| 289 |
287 def Measure(self, platform, results): | 290 def Measure(self, platform, results): |
288 """Collect all possible metrics and added them to results.""" | 291 """Collect all possible metrics and added them to results.""" |
289 platform.tracing_controller.telemetry_info = results.telemetry_info | 292 platform.tracing_controller.telemetry_info = results.telemetry_info |
290 trace_result = platform.tracing_controller.StopTracing() | 293 trace_result = platform.tracing_controller.StopTracing() |
291 trace_value = trace.TraceValue(results.current_page, trace_result) | 294 trace_value = trace.TraceValue(results.current_page, trace_result) |
292 results.AddValue(trace_value) | 295 results.AddValue(trace_value) |
293 | 296 |
294 try: | 297 if self.GetTimelineBasedMetrics(): |
295 if self._tbm_options.GetTimelineBasedMetrics(): | 298 self._ComputeTimelineBasedMetrics(results, trace_value) |
296 assert not self._tbm_options.GetLegacyTimelineBasedMetrics(), ( | 299 # Legacy metrics can be computed, but only if explicitly specified. |
297 'Specifying both TBMv1 and TBMv2 metrics is not allowed.') | 300 if self._tbm_options.GetLegacyTimelineBasedMetrics(): |
298 self._ComputeTimelineBasedMetrics(results, trace_value) | 301 # Since this imports the trace model in python, it will also clean up |
| 302 # the trace handles for us. |
| 303 self._ComputeLegacyTimelineBasedMetrics(results, trace_result) |
299 else: | 304 else: |
300 # Run all TBMv1 metrics if no other metric is specified | 305 # Run all TBMv1 metrics if no other metric is specified |
301 # (legacy behavior) | 306 # (legacy behavior) |
302 if not self._tbm_options.GetLegacyTimelineBasedMetrics(): | 307 if not self._tbm_options.GetLegacyTimelineBasedMetrics(): |
303 logging.warn('Please specify the TBMv1 metrics you are interested in ' | 308 logging.warn('Please specify the TBMv1 metrics you are interested in ' |
304 'explicitly. This implicit functionality will be removed' | 309 'explicitly. This implicit functionality will be removed' |
305 ' on July 17, 2016.') | 310 ' on July 17, 2016.') |
306 self._tbm_options.SetLegacyTimelineBasedMetrics( | 311 self._tbm_options.SetLegacyTimelineBasedMetrics( |
307 _GetAllLegacyTimelineBasedMetrics()) | 312 _GetAllLegacyTimelineBasedMetrics()) |
308 self._ComputeLegacyTimelineBasedMetrics(results, trace_result) | 313 self._ComputeLegacyTimelineBasedMetrics(results, trace_result) |
309 finally: | 314 finally: |
310 trace_result.CleanUpAllTraces() | 315 trace_result.CleanUpAllTraces() |
311 | 316 |
312 def DidRunStory(self, platform): | 317 def DidRunStory(self, platform): |
313 """Clean up after running the story.""" | 318 """Clean up after running the story.""" |
314 if platform.tracing_controller.is_tracing_running: | 319 if platform.tracing_controller.is_tracing_running: |
315 platform.tracing_controller.StopTracing() | 320 platform.tracing_controller.StopTracing() |
316 | 321 |
317 def _ComputeTimelineBasedMetrics(self, results, trace_value): | 322 def _ComputeTimelineBasedMetrics(self, results, trace_value): |
318 metrics = self._tbm_options.GetTimelineBasedMetrics() | 323 metrics = self.GetTimelineBasedMetrics() |
319 extra_import_options = { | 324 extra_import_options = { |
320 'trackDetailedModelStats': True | 325 'trackDetailedModelStats': True |
321 } | 326 } |
322 | 327 |
323 mre_result = metric_runner.RunMetric( | 328 mre_result = metric_runner.RunMetric( |
324 trace_value.filename, metrics, extra_import_options) | 329 trace_value.filename, metrics, extra_import_options) |
325 page = results.current_page | 330 page = results.current_page |
326 | 331 |
327 failure_dicts = mre_result.failures | 332 failure_dicts = mre_result.failures |
328 for d in failure_dicts: | 333 for d in failure_dicts: |
(...skipping 20 matching lines...) Expand all Loading... |
349 | 354 |
350 for renderer_thread, interaction_records in ( | 355 for renderer_thread, interaction_records in ( |
351 threads_to_records_map.iteritems()): | 356 threads_to_records_map.iteritems()): |
352 meta_metrics = _TimelineBasedMetrics( | 357 meta_metrics = _TimelineBasedMetrics( |
353 model, renderer_thread, interaction_records, self._results_wrapper, | 358 model, renderer_thread, interaction_records, self._results_wrapper, |
354 all_metrics) | 359 all_metrics) |
355 meta_metrics.AddResults(results) | 360 meta_metrics.AddResults(results) |
356 | 361 |
357 for metric in all_metrics: | 362 for metric in all_metrics: |
358 metric.AddWholeTraceResults(model, results) | 363 metric.AddWholeTraceResults(model, results) |
OLD | NEW |