| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 page_sets.system_health import platforms | 5 from page_sets.system_health import platforms |
| 6 | 6 |
| 7 from telemetry.page import page | 7 from telemetry.page import page |
| 8 | 8 |
| 9 | 9 |
| 10 # Extra wait time after the page has loaded required by the loading metric. We | 10 # Extra wait time after the page has loaded required by the loading metric. We |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 def __init__(self, story_set, take_memory_measurement): | 41 def __init__(self, story_set, take_memory_measurement): |
| 42 case, group, _ = self.NAME.split(':') | 42 case, group, _ = self.NAME.split(':') |
| 43 super(SystemHealthStory, self).__init__( | 43 super(SystemHealthStory, self).__init__( |
| 44 page_set=story_set, name=self.NAME, url=self.URL, | 44 page_set=story_set, name=self.NAME, url=self.URL, |
| 45 credentials_path='../data/credentials.json', | 45 credentials_path='../data/credentials.json', |
| 46 grouping_keys={'case': case, 'group': group}) | 46 grouping_keys={'case': case, 'group': group}) |
| 47 self._take_memory_measurement = take_memory_measurement | 47 self._take_memory_measurement = take_memory_measurement |
| 48 | 48 |
| 49 def _Measure(self, action_runner): | 49 def _Measure(self, action_runner): |
| 50 if self._ShouldMeasureMemory(action_runner): | 50 if self._take_memory_measurement: |
| 51 action_runner.MeasureMemory(deterministic_mode=True) | 51 action_runner.MeasureMemory(deterministic_mode=True) |
| 52 else: | 52 else: |
| 53 action_runner.Wait(_WAIT_TIME_AFTER_LOAD) | 53 action_runner.Wait(_WAIT_TIME_AFTER_LOAD) |
| 54 | 54 |
| 55 def _ShouldMeasureMemory(self, action_runner): | |
| 56 if not self._take_memory_measurement: | |
| 57 return False | |
| 58 # The check below is also performed in action_runner.MeasureMemory(). | |
| 59 # However, we need to duplicate it here so that the story would wait for | |
| 60 # |_WAIT_TIME_AFTER_LOAD| seconds after load when recorded via the | |
| 61 # system_health.memory_* benchmarks. | |
| 62 # TODO(petrcermak): Make it possible (and mandatory) to record the story | |
| 63 # directly through the story set and remove this check. | |
| 64 tracing_controller = action_runner.tab.browser.platform.tracing_controller | |
| 65 if not tracing_controller.is_tracing_running: | |
| 66 return False # Tracing is not running, e.g. when recording a WPR archive. | |
| 67 return True | |
| 68 | |
| 69 def _Login(self, action_runner): | 55 def _Login(self, action_runner): |
| 70 pass | 56 pass |
| 71 | 57 |
| 72 def _DidLoadDocument(self, action_runner): | 58 def _DidLoadDocument(self, action_runner): |
| 73 pass | 59 pass |
| 74 | 60 |
| 75 def RunNavigateSteps(self, action_runner): | 61 def RunNavigateSteps(self, action_runner): |
| 76 self._Login(action_runner) | 62 self._Login(action_runner) |
| 77 super(SystemHealthStory, self).RunNavigateSteps(action_runner) | 63 super(SystemHealthStory, self).RunNavigateSteps(action_runner) |
| 78 | 64 |
| 79 def RunPageInteractions(self, action_runner): | 65 def RunPageInteractions(self, action_runner): |
| 80 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 66 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 81 self._DidLoadDocument(action_runner) | 67 self._DidLoadDocument(action_runner) |
| 82 self._Measure(action_runner) | 68 self._Measure(action_runner) |
| OLD | NEW |