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

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

Issue 2804473002: Rough prototype of deferred TBM results processing.
Patch Set: Created 3 years, 8 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/internal/results/story_run.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 import threading
7 8
8 from tracing.metrics import metric_runner 9 from tracing.metrics import metric_runner
9 10
10 from telemetry.timeline import chrome_trace_category_filter 11 from telemetry.timeline import chrome_trace_category_filter
11 from telemetry.timeline import model as model_module 12 from telemetry.timeline import model as model_module
12 from telemetry.timeline import tracing_config 13 from telemetry.timeline import tracing_config
13 from telemetry.value import trace 14 from telemetry.value import trace
14 from telemetry.value import common_value_helpers 15 from telemetry.value import common_value_helpers
15 from telemetry.web_perf.metrics import timeline_based_metric 16 from telemetry.web_perf.metrics import timeline_based_metric
16 from telemetry.web_perf.metrics import blob_timeline 17 from telemetry.web_perf.metrics import blob_timeline
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 self._results = None 67 self._results = None
67 68
68 def SetResults(self, results): 69 def SetResults(self, results):
69 self._results = results 70 self._results = results
70 71
71 def SetTirLabel(self, tir_label): 72 def SetTirLabel(self, tir_label):
72 self._tir_label = tir_label 73 self._tir_label = tir_label
73 74
74 @property 75 @property
75 def current_page(self): 76 def current_page(self):
76 return self._results.current_page 77 return self._results.story
77 78
78 def AddValue(self, value): 79 def AddValue(self, value):
79 raise NotImplementedError 80 raise NotImplementedError
80 81
81 82
82 class _TBMResultWrapper(ResultsWrapperInterface): 83 class _TBMResultWrapper(ResultsWrapperInterface):
83 def AddValue(self, value): 84 def AddValue(self, value):
84 assert self._tir_label 85 assert self._tir_label
85 if value.tir_label: 86 if value.tir_label:
86 assert value.tir_label == self._tir_label 87 assert value.tir_label == self._tir_label
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 if self._tbm_options.config.enable_chrome_trace: 278 if self._tbm_options.config.enable_chrome_trace:
278 # Always enable 'blink.console' category for: 279 # Always enable 'blink.console' category for:
279 # 1) Backward compat of chrome clock sync (crbug.com/646925) 280 # 1) Backward compat of chrome clock sync (crbug.com/646925)
280 # 2) Allows users to add trace event through javascript. 281 # 2) Allows users to add trace event through javascript.
281 # Note that blink.console is extremely low-overhead, so this doesn't 282 # Note that blink.console is extremely low-overhead, so this doesn't
282 # affect the tracing overhead budget much. 283 # affect the tracing overhead budget much.
283 chrome_config = self._tbm_options.config.chrome_trace_config 284 chrome_config = self._tbm_options.config.chrome_trace_config
284 chrome_config.category_filter.AddIncludedCategory('blink.console') 285 chrome_config.category_filter.AddIncludedCategory('blink.console')
285 platform.tracing_controller.StartTracing(self._tbm_options.config) 286 platform.tracing_controller.StartTracing(self._tbm_options.config)
286 287
287 def Measure(self, platform, results): 288 def MeasureWorker(self, page_run, trace_result):
288 """Collect all possible metrics and added them to results.""" 289 logging.warn('Running MeasureWorker for %s' % page_run.story.display_name)
289 platform.tracing_controller.telemetry_info = results.telemetry_info 290
290 trace_result = platform.tracing_controller.StopTracing() 291 trace_value = trace.TraceValue(page_run.story, trace_result)
291 trace_value = trace.TraceValue(results.current_page, trace_result) 292 page_run.AddValue(trace_value)
292 results.AddValue(trace_value)
293 293
294 try: 294 try:
295 if self._tbm_options.GetTimelineBasedMetrics(): 295 if self._tbm_options.GetTimelineBasedMetrics():
296 assert not self._tbm_options.GetLegacyTimelineBasedMetrics(), ( 296 assert not self._tbm_options.GetLegacyTimelineBasedMetrics(), (
297 'Specifying both TBMv1 and TBMv2 metrics is not allowed.') 297 'Specifying both TBMv1 and TBMv2 metrics is not allowed.')
298 self._ComputeTimelineBasedMetrics(results, trace_value) 298 logging.warn('running _ComputeTimelineBasedMetrics')
299 self._ComputeTimelineBasedMetrics(page_run, trace_value)
299 else: 300 else:
300 # Run all TBMv1 metrics if no other metric is specified 301 # Run all TBMv1 metrics if no other metric is specified
301 # (legacy behavior) 302 # (legacy behavior)
303 logging.warn('running legacy metrics')
302 if not self._tbm_options.GetLegacyTimelineBasedMetrics(): 304 if not self._tbm_options.GetLegacyTimelineBasedMetrics():
303 logging.warn('Please specify the TBMv1 metrics you are interested in ' 305 logging.warn('Please specify the TBMv1 metrics you are interested in '
304 'explicitly. This implicit functionality will be removed' 306 'explicitly. This implicit functionality will be removed'
305 ' on July 17, 2016.') 307 ' on July 17, 2016.')
306 self._tbm_options.SetLegacyTimelineBasedMetrics( 308 self._tbm_options.SetLegacyTimelineBasedMetrics(
307 _GetAllLegacyTimelineBasedMetrics()) 309 _GetAllLegacyTimelineBasedMetrics())
308 self._ComputeLegacyTimelineBasedMetrics(results, trace_result) 310 self._ComputeLegacyTimelineBasedMetrics(page_run, trace_result)
309 finally: 311 finally:
310 trace_result.CleanUpAllTraces() 312 trace_result.CleanUpAllTraces()
311 313
314
315 def Measure(self, platform, results):
316 """Collect all possible metrics and added them to results."""
317 platform.tracing_controller.telemetry_info = results.telemetry_info
318 trace_result = platform.tracing_controller.StopTracing()
319
320 page_run = results.current_page_run
321 thread = threading.Thread(target=TimelineBasedMeasurement.MeasureWorker,
322 args=(self, page_run, trace_result,))
323 page_run.AddResultThread(thread)
324 thread.start()
325
312 def DidRunStory(self, platform): 326 def DidRunStory(self, platform):
313 """Clean up after running the story.""" 327 """Clean up after running the story."""
314 if platform.tracing_controller.is_tracing_running: 328 if platform.tracing_controller.is_tracing_running:
315 platform.tracing_controller.StopTracing() 329 platform.tracing_controller.StopTracing()
316 330
317 def _ComputeTimelineBasedMetrics(self, results, trace_value): 331 def _ComputeTimelineBasedMetrics(self, results, trace_value):
318 metrics = self._tbm_options.GetTimelineBasedMetrics() 332 metrics = self._tbm_options.GetTimelineBasedMetrics()
319 extra_import_options = { 333 extra_import_options = {
320 'trackDetailedModelStats': True 334 'trackDetailedModelStats': True
321 } 335 }
(...skipping 27 matching lines...) Expand all
349 363
350 for renderer_thread, interaction_records in ( 364 for renderer_thread, interaction_records in (
351 threads_to_records_map.iteritems()): 365 threads_to_records_map.iteritems()):
352 meta_metrics = _TimelineBasedMetrics( 366 meta_metrics = _TimelineBasedMetrics(
353 model, renderer_thread, interaction_records, self._results_wrapper, 367 model, renderer_thread, interaction_records, self._results_wrapper,
354 all_metrics) 368 all_metrics)
355 meta_metrics.AddResults(results) 369 meta_metrics.AddResults(results)
356 370
357 for metric in all_metrics: 371 for metric in all_metrics:
358 metric.AddWholeTraceResults(model, results) 372 metric.AddWholeTraceResults(model, results)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/results/story_run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698