| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 import logging |
| 5 import py_utils |
| 6 |
| 7 from telemetry.page import page as page_module |
| 8 from telemetry.page import shared_page_state |
| 9 from telemetry import story |
| 10 |
| 11 _DUMP_WAIT_TIME = 3 |
| 12 _ITERATIONS = 10 |
| 13 |
| 14 class DesktopMemoryPage(page_module.Page): |
| 15 |
| 16 def __init__(self, url, page_set): |
| 17 super(DesktopMemoryPage, self).__init__( |
| 18 url=url, page_set=page_set, |
| 19 shared_page_state_class=shared_page_state.SharedDesktopPageState) |
| 20 |
| 21 def _DumpMemory(self, action_runner, phase): |
| 22 with action_runner.CreateInteraction(phase): |
| 23 action_runner.Wait(_DUMP_WAIT_TIME) |
| 24 action_runner.ForceGarbageCollection() |
| 25 action_runner.SimulateMemoryPressureNotification('critical') |
| 26 action_runner.Wait(_DUMP_WAIT_TIME) |
| 27 # action_runner.MeasureMemory(deterministic_mode=False) |
| 28 action_runner.tab.browser.DumpMemory() |
| 29 |
| 30 def RunPageInteractions(self, action_runner): |
| 31 self._DumpMemory(action_runner, 'pre') |
| 32 for _ in xrange(_ITERATIONS): |
| 33 action_runner.ReloadPage() |
| 34 |
| 35 tabs = action_runner.tab.browser.tabs |
| 36 for _ in xrange(_ITERATIONS): |
| 37 new_tab = tabs.New() |
| 38 new_tab.action_runner.Navigate(self._url) |
| 39 try: |
| 40 new_tab.action_runner.WaitForNetworkQuiescence() |
| 41 except py_utils.TimeoutException: |
| 42 logging.warning('WaitForNetworkQuiescence() timeout') |
| 43 new_tab.Close() |
| 44 |
| 45 self._DumpMemory(action_runner, 'post') |
| 46 |
| 47 |
| 48 class DesktopMemoryPageSet(story.StorySet): |
| 49 |
| 50 """ Desktop sites with interesting memory characteristics """ |
| 51 |
| 52 def __init__(self): |
| 53 super(DesktopMemoryPageSet, self).__init__( |
| 54 archive_data_file='data/mobile_memory.json', |
| 55 cloud_storage_bucket=story.PARTNER_BUCKET) |
| 56 |
| 57 urls_list = [ |
| 58 'http://www.perdu.com', |
| 59 'http://www.google.com', |
| 60 "http://www.live.com", |
| 61 "http://www.youtube.com", |
| 62 "http://www.wikipedia.org", |
| 63 "http://www.flickr.com/", |
| 64 "http://www.cnn.com/", |
| 65 "http://www.adobe.com/", |
| 66 "http://www.aol.com/", |
| 67 "http://www.cnet.com/", |
| 68 "http://www.godaddy.com/", |
| 69 "http://www.walmart.com/", |
| 70 "http://www.skype.com/", |
| 71 ] |
| 72 |
| 73 for url in urls_list: |
| 74 self.AddStory(DesktopMemoryPage(url, self)) |
| 75 |
| OLD | NEW |