| 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 telemetry.util import image_util | 5 from telemetry.util import image_util |
| 6 from telemetry.util import rgba_color | 6 from telemetry.util import rgba_color |
| 7 from telemetry.value import scalar | 7 from telemetry.value import scalar |
| 8 | 8 |
| 9 from metrics import Metric | 9 from metrics import Metric |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 def Stop(self, _, tab): | 43 def Stop(self, _, tab): |
| 44 """Stop recording.""" | 44 """Stop recording.""" |
| 45 if not tab.video_capture_supported: | 45 if not tab.video_capture_supported: |
| 46 return | 46 return |
| 47 assert self._impl, 'Must call Start() before Stop()' | 47 assert self._impl, 'Must call Start() before Stop()' |
| 48 assert self.IsFinished(tab), 'Must wait for IsFinished() before Stop()' | 48 assert self.IsFinished(tab), 'Must wait for IsFinished() before Stop()' |
| 49 self._impl.Stop(tab) | 49 self._impl.Stop(tab) |
| 50 | 50 |
| 51 # Optional argument chart_name is not in base class Metric. | 51 # Optional argument chart_name is not in base class Metric. |
| 52 # pylint: disable=W0221 | 52 # pylint: disable=arguments-differ |
| 53 def AddResults(self, tab, results, chart_name=None): | 53 def AddResults(self, tab, results, chart_name=None): |
| 54 """Calculate the speed index and add it to the results.""" | 54 """Calculate the speed index and add it to the results.""" |
| 55 try: | 55 try: |
| 56 if tab.video_capture_supported: | 56 if tab.video_capture_supported: |
| 57 index = self._impl.CalculateSpeedIndex(tab) | 57 index = self._impl.CalculateSpeedIndex(tab) |
| 58 none_value_reason = None | 58 none_value_reason = None |
| 59 else: | 59 else: |
| 60 index = None | 60 index = None |
| 61 none_value_reason = 'Video capture is not supported.' | 61 none_value_reason = 'Video capture is not supported.' |
| 62 finally: | 62 finally: |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 else: | 179 else: |
| 180 return 0.0 | 180 return 0.0 |
| 181 return 1 - histogram.Distance(final_histogram) / total_distance | 181 return 1 - histogram.Distance(final_histogram) / total_distance |
| 182 | 182 |
| 183 self._time_completeness_list = [(time, FrameProgress(hist)) | 183 self._time_completeness_list = [(time, FrameProgress(hist)) |
| 184 for time, hist in histograms] | 184 for time, hist in histograms] |
| 185 | 185 |
| 186 def GetTimeCompletenessList(self, tab): | 186 def GetTimeCompletenessList(self, tab): |
| 187 assert self._time_completeness_list, 'Must call Stop() first.' | 187 assert self._time_completeness_list, 'Must call Stop() first.' |
| 188 return self._time_completeness_list | 188 return self._time_completeness_list |
| OLD | NEW |