| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 | 5 import logging |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 from telemetry.page import page as page_module | 8 from telemetry.page import page as page_module |
| 9 from telemetry.page import shared_page_state | 9 from telemetry.page import shared_page_state |
| 10 from telemetry import story | 10 from telemetry import story |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 ] | 29 ] |
| 30 | 30 |
| 31 | 31 |
| 32 class ForegroundPage(page_module.Page): | 32 class ForegroundPage(page_module.Page): |
| 33 """Take a measurement after loading a regular webpage.""" | 33 """Take a measurement after loading a regular webpage.""" |
| 34 | 34 |
| 35 def __init__(self, story_set, name, url): | 35 def __init__(self, story_set, name, url): |
| 36 super(ForegroundPage, self).__init__( | 36 super(ForegroundPage, self).__init__( |
| 37 url=url, page_set=story_set, name=name, | 37 url=url, page_set=story_set, name=name, |
| 38 shared_page_state_class=shared_page_state.SharedMobilePageState) | 38 shared_page_state_class=shared_page_state.SharedMobilePageState) |
| 39 self.archive_data_file = story_set.archive_data_file | |
| 40 | 39 |
| 41 def _TakeMemoryMeasurement(self, action_runner, phase): | 40 def _TakeMemoryMeasurement(self, action_runner, phase): |
| 42 action_runner.Wait(1) # See crbug.com/540022#c17. | 41 action_runner.Wait(1) # See crbug.com/540022#c17. |
| 43 with action_runner.CreateInteraction(phase): | 42 with action_runner.CreateInteraction(phase): |
| 44 action_runner.Wait(DUMP_WAIT_TIME) | 43 action_runner.Wait(DUMP_WAIT_TIME) |
| 45 action_runner.ForceGarbageCollection() | 44 action_runner.ForceGarbageCollection() |
| 46 action_runner.tab.browser.platform.FlushEntireSystemCache() | 45 action_runner.tab.browser.platform.FlushEntireSystemCache() |
| 47 action_runner.Wait(DUMP_WAIT_TIME) | 46 action_runner.Wait(DUMP_WAIT_TIME) |
| 48 if not action_runner.tab.browser.DumpMemory(): | 47 if not action_runner.tab.browser.DumpMemory(): |
| 49 logging.error('Unable to get a memory dump for %s.', self.name) | 48 logging.error('Unable to get a memory dump for %s.', self.name) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 archive_data_file='data/memory_health_plan.json', | 83 archive_data_file='data/memory_health_plan.json', |
| 85 cloud_storage_bucket=story.PARTNER_BUCKET) | 84 cloud_storage_bucket=story.PARTNER_BUCKET) |
| 86 | 85 |
| 87 for url in URL_LIST: | 86 for url in URL_LIST: |
| 88 # We name pages so their foreground/background counterparts are easy | 87 # We name pages so their foreground/background counterparts are easy |
| 89 # to identify. For example 'http://google.com' becomes | 88 # to identify. For example 'http://google.com' becomes |
| 90 # 'http_google_com' and 'after_http_google_com' respectively. | 89 # 'http_google_com' and 'after_http_google_com' respectively. |
| 91 name = re.sub('\W+', '_', url) | 90 name = re.sub('\W+', '_', url) |
| 92 self.AddStory(ForegroundPage(self, name, url)) | 91 self.AddStory(ForegroundPage(self, name, url)) |
| 93 self.AddStory(BackgroundPage(self, 'after_' + name)) | 92 self.AddStory(BackgroundPage(self, 'after_' + name)) |
| OLD | NEW |