| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 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 | 4 |
| 5 from metrics import Metric | 5 from metrics import Metric |
| 6 from metrics import rendering_stats | 6 from metrics import rendering_stats |
| 7 from metrics import statistics | 7 from metrics import statistics |
| 8 from telemetry.page import page_measurement | 8 from telemetry.page import page_measurement |
| 9 from telemetry.page.perf_tests_helper import FlattenList | 9 from telemetry.page.perf_tests_helper import FlattenList |
| 10 | 10 |
| 11 TIMELINE_MARKER = 'Smoothness' | 11 TIMELINE_MARKER = 'Smoothness' |
| 12 | 12 |
| 13 | 13 |
| 14 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): | 14 class MissingDisplayFrameRateError(page_measurement.MeasurementFailure): |
| 15 def __init__(self, name): | 15 def __init__(self, name): |
| 16 super(MissingDisplayFrameRateError, self).__init__( | 16 super(MissingDisplayFrameRateError, self).__init__( |
| 17 'Missing display frame rate metrics: ' + name) | 17 'Missing display frame rate metrics: ' + name) |
| 18 | 18 |
| 19 | |
| 20 class NotEnoughFramesError(page_measurement.MeasurementFailure): | 19 class NotEnoughFramesError(page_measurement.MeasurementFailure): |
| 21 def __init__(self): | 20 def __init__(self): |
| 22 super(NotEnoughFramesError, self).__init__( | 21 super(NotEnoughFramesError, self).__init__( |
| 23 'Page output less than two frames') | 22 'Page output less than two frames') |
| 24 | 23 |
| 25 | 24 |
| 26 class NoSupportedActionError(page_measurement.MeasurementFailure): | 25 class NoSupportedActionError(page_measurement.MeasurementFailure): |
| 27 def __init__(self): | 26 def __init__(self): |
| 28 super(NoSupportedActionError, self).__init__( | 27 super(NoSupportedActionError, self).__init__( |
| 29 'None of the actions is supported by smoothness measurement') | 28 'None of the actions is supported by smoothness measurement') |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 # Are we hitting 60 fps for 95 percent of all frames? | 128 # Are we hitting 60 fps for 95 percent of all frames? |
| 130 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0. | 129 # We use 19ms as a somewhat looser threshold, instead of 1000.0/60.0. |
| 131 percentile_95 = statistics.Percentile(frame_times, 95.0) | 130 percentile_95 = statistics.Percentile(frame_times, 95.0) |
| 132 results.Add('mostly_smooth', 'score', 1.0 if percentile_95 < 19.0 else 0.0) | 131 results.Add('mostly_smooth', 'score', 1.0 if percentile_95 < 19.0 else 0.0) |
| 133 | 132 |
| 134 if tab.browser.platform.IsRawDisplayFrameRateSupported(): | 133 if tab.browser.platform.IsRawDisplayFrameRateSupported(): |
| 135 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): | 134 for r in tab.browser.platform.GetRawDisplayFrameRateMeasurements(): |
| 136 if r.value is None: | 135 if r.value is None: |
| 137 raise MissingDisplayFrameRateError(r.name) | 136 raise MissingDisplayFrameRateError(r.name) |
| 138 results.Add(r.name, r.unit, r.value) | 137 results.Add(r.name, r.unit, r.value) |
| OLD | NEW |