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