OLD | NEW |
---|---|
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 from metrics import loading | 4 from metrics import loading |
5 from metrics import smoothness | 5 from metrics import smoothness |
6 from metrics.gpu_rendering_stats import GpuRenderingStats | 6 from metrics.gpu_rendering_stats import GpuRenderingStats |
7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
8 | 8 |
9 class DidNotScrollException(page_measurement.MeasurementFailure): | 9 class DidNotScrollException(page_measurement.MeasurementFailure): |
10 def __init__(self): | 10 def __init__(self): |
11 super(DidNotScrollException, self).__init__('Page did not scroll') | 11 super(DidNotScrollException, self).__init__('Page did not scroll') |
12 | 12 |
13 class MissingDisplayFrameRate(page_measurement.MeasurementFailure): | 13 class MissingDisplayFrameRate(page_measurement.MeasurementFailure): |
14 def __init__(self, name): | 14 def __init__(self, name): |
15 super(MissingDisplayFrameRate, self).__init__( | 15 super(MissingDisplayFrameRate, self).__init__( |
16 'Missing display frame rate metrics: ' + name) | 16 'Missing display frame rate metrics: ' + name) |
17 | 17 |
bulach
2013/09/05 10:30:33
ultra nit: not your fault, but there should be two
| |
18 class MissingTimelineMarker(page_measurement.MeasurementFailure): | |
19 def __init__(self): | |
20 super(MissingTimelineMarker, self).__init__('Timeline marker not found') | |
21 | |
18 class Smoothness(page_measurement.PageMeasurement): | 22 class Smoothness(page_measurement.PageMeasurement): |
19 def __init__(self): | 23 def __init__(self): |
20 super(Smoothness, self).__init__('smoothness') | 24 super(Smoothness, self).__init__('smoothness') |
21 self.force_enable_threaded_compositing = False | 25 self.force_enable_threaded_compositing = False |
22 self._metrics = None | 26 self._metrics = None |
23 | 27 |
24 def AddCommandLineOptions(self, parser): | 28 def AddCommandLineOptions(self, parser): |
25 parser.add_option('--report-all-results', dest='report_all_results', | 29 parser.add_option('--report-all-results', dest='report_all_results', |
26 action='store_true', | 30 action='store_true', |
27 help='Reports all data collected, not just FPS') | 31 help='Reports all data collected, not just FPS') |
(...skipping 22 matching lines...) Expand all Loading... | |
50 if not action.CanBeBound(): | 54 if not action.CanBeBound(): |
51 self._metrics.Stop() | 55 self._metrics.Stop() |
52 tab.browser.StopTracing() | 56 tab.browser.StopTracing() |
53 | 57 |
54 def FindTimelineMarker(self, timeline): | 58 def FindTimelineMarker(self, timeline): |
55 events = [s for | 59 events = [s for |
56 s in timeline.GetAllEventsOfName( | 60 s in timeline.GetAllEventsOfName( |
57 smoothness.TIMELINE_MARKER) | 61 smoothness.TIMELINE_MARKER) |
58 if s.parent_slice == None] | 62 if s.parent_slice == None] |
59 if len(events) != 1: | 63 if len(events) != 1: |
60 raise LookupError, 'timeline marker not found' | 64 raise MissingTimelineMarker() |
61 return events[0] | 65 return events[0] |
62 | 66 |
63 def MeasurePage(self, page, tab, results): | 67 def MeasurePage(self, page, tab, results): |
64 rendering_stats_deltas = self._metrics.deltas | 68 rendering_stats_deltas = self._metrics.deltas |
65 | 69 |
66 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): | 70 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): |
67 raise DidNotScrollException() | 71 raise DidNotScrollException() |
68 | 72 |
69 loading.LoadingMetric().AddResults(tab, results) | 73 loading.LoadingMetric().AddResults(tab, results) |
70 | 74 |
71 smoothness.CalcFirstPaintTimeResults(results, tab) | 75 smoothness.CalcFirstPaintTimeResults(results, tab) |
72 | 76 |
73 timeline = tab.browser.GetTraceResultAndReset().AsTimelineModel() | 77 timeline = tab.browser.GetTraceResultAndReset().AsTimelineModel() |
74 timeline_marker = self.FindTimelineMarker(timeline) | 78 timeline_marker = self.FindTimelineMarker(timeline) |
75 benchmark_stats = GpuRenderingStats(timeline_marker, | 79 benchmark_stats = GpuRenderingStats(timeline_marker, |
76 rendering_stats_deltas, | 80 rendering_stats_deltas, |
77 self._metrics.is_using_gpu_benchmarking) | 81 self._metrics.is_using_gpu_benchmarking) |
78 smoothness.CalcResults(benchmark_stats, results) | 82 smoothness.CalcResults(benchmark_stats, results) |
79 | 83 |
80 if self.options.report_all_results: | 84 if self.options.report_all_results: |
81 for k, v in rendering_stats_deltas.iteritems(): | 85 for k, v in rendering_stats_deltas.iteritems(): |
82 results.Add(k, '', v) | 86 results.Add(k, '', v) |
83 | 87 |
84 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 88 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
85 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 89 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
86 if r.value is None: | 90 if r.value is None: |
87 raise MissingDisplayFrameRate(r.name) | 91 raise MissingDisplayFrameRate(r.name) |
88 results.Add(r.name, r.unit, r.value) | 92 results.Add(r.name, r.unit, r.value) |
OLD | NEW |