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

Side by Side Diff: tools/perf/measurements/timeline_based_measurement.py

Issue 170183004: Move smoothness to the new API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit
Patch Set: Created 6 years, 9 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
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 4
5 from metrics import timeline as timeline_module 5 from metrics import timeline as timeline_module
6 from metrics import timeline_interaction_record as tir_module 6 from metrics import timeline_interaction_record as tir_module
7 from metrics import smoothness
7 from telemetry.page import page_measurement 8 from telemetry.page import page_measurement
8 from telemetry.core.timeline import model as model_module 9 from telemetry.core.timeline import model as model_module
9 10
10 11
11
12 # TimelineBasedMeasurement considers all instrumentation as producing a single 12 # TimelineBasedMeasurement considers all instrumentation as producing a single
13 # timeline. But, depending on the amount of instrumentation that is enabled, 13 # timeline. But, depending on the amount of instrumentation that is enabled,
14 # overhead increases. The user of the measurement must therefore chose between 14 # overhead increases. The user of the measurement must therefore chose between
15 # a few levels of instrumentation. 15 # a few levels of instrumentation.
16 NO_OVERHEAD_LEVEL = 'no-overhead' 16 NO_OVERHEAD_LEVEL = 'no-overhead'
17 MINIMAL_OVERHEAD_LEVEL = 'minimal-overhead' 17 MINIMAL_OVERHEAD_LEVEL = 'minimal-overhead'
18 DEBUG_OVERHEAD_LEVEL = 'debug-overhead' 18 DEBUG_OVERHEAD_LEVEL = 'debug-overhead'
19 19
20 ALL_OVERHEAD_LEVELS = [ 20 ALL_OVERHEAD_LEVELS = [
21 NO_OVERHEAD_LEVEL, 21 NO_OVERHEAD_LEVEL,
22 MINIMAL_OVERHEAD_LEVEL, 22 MINIMAL_OVERHEAD_LEVEL,
23 DEBUG_OVERHEAD_LEVEL 23 DEBUG_OVERHEAD_LEVEL
24 ] 24 ]
25 25
26 26
27 class _TimelineBasedMetrics(object): 27 class _TimelineBasedMetrics(object):
28 def __init__(self, model, renderer_thread): 28 def __init__(self, model, renderer_thread):
29 self._model = model 29 self._model = model
30 self._renderer_thread = renderer_thread 30 self._renderer_thread = renderer_thread
31 31
32 def FindTimelineInteractionRecords(self): 32 def FindTimelineInteractionRecords(self):
33 # TODO(nduca): Add support for page-load interaction record. 33 # TODO(nduca): Add support for page-load interaction record.
34 return [tir_module.TimelineInteractionRecord(event) for 34 return [tir_module.TimelineInteractionRecord.FromEvent(event) for
35 event in self._renderer_thread.IterAllAsyncSlices() 35 event in self._renderer_thread.IterAllAsyncSlices()
36 if tir_module.IsTimelineInteractionRecord(event.name)] 36 if tir_module.IsTimelineInteractionRecord(event.name)]
37 37
38 def CreateMetricsForTimelineInteractionRecord(self, interaction): 38 def CreateMetricsForTimelineInteractionRecord(self, interaction):
39 res = [] 39 res = []
40 if interaction.is_smooth: 40 if interaction.is_smooth:
41 pass # TODO(nduca): res.append smoothness metric instance. 41 res.append(smoothness.SmoothnessMetric())
42 return res 42 return res
43 43
44 def AddResults(self, results): 44 def AddResults(self, results):
45 interactions = self.FindTimelineInteractionRecords() 45 interactions = self.FindTimelineInteractionRecords()
46 if len(interactions) == 0: 46 if len(interactions) == 0:
47 raise Exception('Expected at least one Interaction on the page') 47 raise Exception('Expected at least one Interaction on the page')
48 for interaction in interactions: 48 for interaction in interactions:
49 metrics = self.CreateMetricsForTimelineInteractionRecord(interaction) 49 metrics = self.CreateMetricsForTimelineInteractionRecord(interaction)
50 for m in metrics: 50 for m in metrics:
51 m.AddResults(self._model, self._renderer_thread, 51 m.AddResults(self._model, self._renderer_thread,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 categories = '*,disabled-by-default-cc.debug' 101 categories = '*,disabled-by-default-cc.debug'
102 tab.browser.StartTracing(categories) 102 tab.browser.StartTracing(categories)
103 103
104 def MeasurePage(self, page, tab, results): 104 def MeasurePage(self, page, tab, results):
105 """ Collect all possible metrics and added them to results. """ 105 """ Collect all possible metrics and added them to results. """
106 trace_result = tab.browser.StopTracing() 106 trace_result = tab.browser.StopTracing()
107 model = model_module.TimelineModel(trace_result) 107 model = model_module.TimelineModel(trace_result)
108 renderer_thread = model.GetRendererThreadFromTab(tab) 108 renderer_thread = model.GetRendererThreadFromTab(tab)
109 meta_metrics = _TimelineBasedMetrics(model, renderer_thread) 109 meta_metrics = _TimelineBasedMetrics(model, renderer_thread)
110 meta_metrics.AddResults(results) 110 meta_metrics.AddResults(results)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698