Chromium Code Reviews| 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 import logging | |
| 6 | |
| 7 from page_sets.system_health import platforms | 5 from page_sets.system_health import platforms |
| 8 | 6 |
| 9 from telemetry.page import page | 7 from telemetry.page import page |
| 10 | 8 |
| 11 | 9 |
| 12 _DUMP_WAIT_TIME = 3 | 10 # Extra wait time after the page has loaded required by the loading metric. We |
| 11 # use it in all benchmarks to avoid divergence between benchmarks. | |
| 12 # TODO(petrcermak): Switch the memory benchmarks to use it as well. | |
| 13 _WAIT_TIME_AFTER_LOAD = 10 | |
| 13 | 14 |
| 14 | 15 |
| 15 class _MetaSystemHealthStory(type): | 16 class _MetaSystemHealthStory(type): |
| 16 """Metaclass for SystemHealthStory.""" | 17 """Metaclass for SystemHealthStory.""" |
| 17 | 18 |
| 18 @property | 19 @property |
| 19 def ABSTRACT_STORY(cls): | 20 def ABSTRACT_STORY(cls): |
| 20 """Class field marking whether the class is abstract. | 21 """Class field marking whether the class is abstract. |
| 21 | 22 |
| 22 If true, the story will NOT be instantiated and added to a System Health | 23 If true, the story will NOT be instantiated and added to a System Health |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 39 | 40 |
| 40 def __init__(self, story_set, take_memory_measurement): | 41 def __init__(self, story_set, take_memory_measurement): |
| 41 case, group, _ = self.NAME.split(':') | 42 case, group, _ = self.NAME.split(':') |
| 42 super(SystemHealthStory, self).__init__( | 43 super(SystemHealthStory, self).__init__( |
| 43 page_set=story_set, name=self.NAME, url=self.URL, | 44 page_set=story_set, name=self.NAME, url=self.URL, |
| 44 credentials_path='../data/credentials.json', | 45 credentials_path='../data/credentials.json', |
| 45 grouping_keys={'case': case, 'group': group}) | 46 grouping_keys={'case': case, 'group': group}) |
| 46 self._take_memory_measurement = take_memory_measurement | 47 self._take_memory_measurement = take_memory_measurement |
| 47 | 48 |
| 48 def _Measure(self, action_runner): | 49 def _Measure(self, action_runner): |
| 50 if self._ShouldMeasureMemory(action_runner): | |
| 51 action_runner.MeasureMemory(deterministic_mode=True) | |
| 52 else: | |
| 53 action_runner.Wait(_WAIT_TIME_AFTER_LOAD) | |
| 54 | |
| 55 def _ShouldMeasureMemory(self, action_runner): | |
| 49 if not self._take_memory_measurement: | 56 if not self._take_memory_measurement: |
| 50 return | 57 return False |
| 51 # TODO(petrcermak): This method is essentially the same as | |
| 52 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py. | |
| 53 # Consider sharing the common code. | |
| 54 action_runner.Wait(_DUMP_WAIT_TIME) | |
| 55 action_runner.ForceGarbageCollection() | |
| 56 action_runner.Wait(_DUMP_WAIT_TIME) | |
| 57 tracing_controller = action_runner.tab.browser.platform.tracing_controller | 58 tracing_controller = action_runner.tab.browser.platform.tracing_controller |
| 58 if not tracing_controller.is_tracing_running: | 59 if not tracing_controller.is_tracing_running: |
| 59 return # Tracing is not running, e.g., when recording a WPR archive. | 60 return False # Tracing is not running, e.g. when recording a WPR archive. |
| 60 if not action_runner.tab.browser.DumpMemory(): | 61 return True |
|
perezju
2016/08/17 16:24:45
This check is already happening within MeasureMemo
petrcermak
2016/08/23 14:34:39
We actually need this for when we record the stori
| |
| 61 logging.error('Unable to get a memory dump for %s.', self.name) | |
| 62 | 62 |
| 63 def _Login(self, action_runner): | 63 def _Login(self, action_runner): |
| 64 pass | 64 pass |
| 65 | 65 |
| 66 def _DidLoadDocument(self, action_runner): | 66 def _DidLoadDocument(self, action_runner): |
| 67 pass | 67 pass |
| 68 | 68 |
| 69 def RunNavigateSteps(self, action_runner): | 69 def RunNavigateSteps(self, action_runner): |
| 70 self._Login(action_runner) | 70 self._Login(action_runner) |
| 71 super(SystemHealthStory, self).RunNavigateSteps(action_runner) | 71 super(SystemHealthStory, self).RunNavigateSteps(action_runner) |
| 72 | 72 |
| 73 def RunPageInteractions(self, action_runner): | 73 def RunPageInteractions(self, action_runner): |
| 74 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 74 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 75 self._DidLoadDocument(action_runner) | 75 self._DidLoadDocument(action_runner) |
| 76 self._Measure(action_runner) | 76 self._Measure(action_runner) |
| OLD | NEW |