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

Side by Side Diff: telemetry/telemetry/web_perf/timeline_based_measurement.py

Issue 2661573003: Refactor TraceData to encapsulate internal traces' representation (Closed)
Patch Set: Address Charlie's comments Created 3 years, 10 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 | « telemetry/telemetry/value/trace_unittest.py ('k') | no next file » | 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 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
11 from telemetry.timeline import model as model_module 11 from telemetry.timeline import model as model_module
12 from telemetry.timeline import tracing_config 12 from telemetry.timeline import tracing_config
13 from telemetry.timeline import trace_data as trace_data_module
14 from telemetry.value import trace 13 from telemetry.value import trace
15 from telemetry.value import common_value_helpers 14 from telemetry.value import common_value_helpers
16 from telemetry.web_perf.metrics import timeline_based_metric 15 from telemetry.web_perf.metrics import timeline_based_metric
17 from telemetry.web_perf.metrics import blob_timeline 16 from telemetry.web_perf.metrics import blob_timeline
18 from telemetry.web_perf.metrics import jitter_timeline 17 from telemetry.web_perf.metrics import jitter_timeline
19 from telemetry.web_perf.metrics import webrtc_rendering_timeline 18 from telemetry.web_perf.metrics import webrtc_rendering_timeline
20 from telemetry.web_perf.metrics import gpu_timeline 19 from telemetry.web_perf.metrics import gpu_timeline
21 from telemetry.web_perf.metrics import indexeddb_timeline 20 from telemetry.web_perf.metrics import indexeddb_timeline
22 from telemetry.web_perf.metrics import layout 21 from telemetry.web_perf.metrics import layout
23 from telemetry.web_perf.metrics import smoothness 22 from telemetry.web_perf.metrics import smoothness
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 chrome_config.category_filter.AddIncludedCategory('blink.console') 284 chrome_config.category_filter.AddIncludedCategory('blink.console')
286 platform.tracing_controller.StartTracing(self._tbm_options.config) 285 platform.tracing_controller.StartTracing(self._tbm_options.config)
287 286
288 def Measure(self, platform, results): 287 def Measure(self, platform, results):
289 """Collect all possible metrics and added them to results.""" 288 """Collect all possible metrics and added them to results."""
290 platform.tracing_controller.telemetry_info = results.telemetry_info 289 platform.tracing_controller.telemetry_info = results.telemetry_info
291 trace_result = platform.tracing_controller.StopTracing() 290 trace_result = platform.tracing_controller.StopTracing()
292 trace_value = trace.TraceValue(results.current_page, trace_result) 291 trace_value = trace.TraceValue(results.current_page, trace_result)
293 results.AddValue(trace_value) 292 results.AddValue(trace_value)
294 293
295 if self._tbm_options.GetTimelineBasedMetrics(): 294 try:
296 self._ComputeTimelineBasedMetrics(results, trace_value) 295 if self._tbm_options.GetTimelineBasedMetrics():
297 # Legacy metrics can be computed, but only if explicitly specified. 296 self._ComputeTimelineBasedMetrics(results, trace_value)
298 if self._tbm_options.GetLegacyTimelineBasedMetrics(): 297 # Legacy metrics can be computed, but only if explicitly specified.
299 # Since this imports the trace model in python, it will also clean up 298 if self._tbm_options.GetLegacyTimelineBasedMetrics():
300 # the trace handles for us. 299 self._ComputeLegacyTimelineBasedMetrics(results, trace_result)
300 else:
301 # Run all TBMv1 metrics if no other metric is specified
302 # (legacy behavior)
303 if not self._tbm_options.GetLegacyTimelineBasedMetrics():
304 logging.warn('Please specify the TBMv1 metrics you are interested in '
305 'explicitly. This implicit functionality will be removed'
306 ' on July 17, 2016.')
307 self._tbm_options.SetLegacyTimelineBasedMetrics(
308 _GetAllLegacyTimelineBasedMetrics())
301 self._ComputeLegacyTimelineBasedMetrics(results, trace_result) 309 self._ComputeLegacyTimelineBasedMetrics(results, trace_result)
302 else: 310 finally:
303 # Clean up the trace handles ourselves if we did not use the python 311 trace_result.CleanUpAllTraces()
304 # trace importer.
305 for data in trace_result.GetTracesFor(
306 trace_data_module.CHROME_TRACE_PART):
307 if isinstance(data, trace_data_module.TraceFileHandle):
308 data.Clean()
309 else:
310 # Run all TBMv1 metrics if no other metric is specified (legacy behavior)
311 if not self._tbm_options.GetLegacyTimelineBasedMetrics():
312 logging.warn('Please specify the TBMv1 metrics you are interested in '
313 'explicitly. This implicit functionality will be removed '
314 'on July 17, 2016.')
315 self._tbm_options.SetLegacyTimelineBasedMetrics(
316 _GetAllLegacyTimelineBasedMetrics())
317 self._ComputeLegacyTimelineBasedMetrics(results, trace_result)
318 312
319 def DidRunStory(self, platform): 313 def DidRunStory(self, platform):
320 """Clean up after running the story.""" 314 """Clean up after running the story."""
321 if platform.tracing_controller.is_tracing_running: 315 if platform.tracing_controller.is_tracing_running:
322 platform.tracing_controller.StopTracing() 316 platform.tracing_controller.StopTracing()
323 317
324 def _ComputeTimelineBasedMetrics(self, results, trace_value): 318 def _ComputeTimelineBasedMetrics(self, results, trace_value):
325 metrics = self._tbm_options.GetTimelineBasedMetrics() 319 metrics = self._tbm_options.GetTimelineBasedMetrics()
326 extra_import_options = { 320 extra_import_options = {
327 'trackDetailedModelStats': True 321 'trackDetailedModelStats': True
(...skipping 28 matching lines...) Expand all
356 350
357 for renderer_thread, interaction_records in ( 351 for renderer_thread, interaction_records in (
358 threads_to_records_map.iteritems()): 352 threads_to_records_map.iteritems()):
359 meta_metrics = _TimelineBasedMetrics( 353 meta_metrics = _TimelineBasedMetrics(
360 model, renderer_thread, interaction_records, self._results_wrapper, 354 model, renderer_thread, interaction_records, self._results_wrapper,
361 all_metrics) 355 all_metrics)
362 meta_metrics.AddResults(results) 356 meta_metrics.AddResults(results)
363 357
364 for metric in all_metrics: 358 for metric in all_metrics:
365 metric.AddWholeTraceResults(model, results) 359 metric.AddWholeTraceResults(model, results)
OLDNEW
« no previous file with comments | « telemetry/telemetry/value/trace_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698