Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: tools/perf/page_sets/memory_top_10_mobile.py

Issue 1936533002: Memory Infra: Replace memory_health_plan with top_10_mobile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 11
12 from devil.android.sdk import intent # pylint: disable=import-error 12 from devil.android.sdk import intent # pylint: disable=import-error
13 from devil.android.sdk import keyevent # pylint: disable=import-error 13 from devil.android.sdk import keyevent # pylint: disable=import-error
14 14
15 from page_sets import top_10_mobile
16
15 17
16 DUMP_WAIT_TIME = 3 18 DUMP_WAIT_TIME = 3
17 19
18 URL_LIST = [
19 'http://google.com',
20 'http://vimeo.com',
21 'http://yahoo.com',
22 'http://baidu.com',
23 'http://cnn.com',
24 'http://yandex.ru',
25 'http://yahoo.co.jp',
26 'http://amazon.com',
27 'http://ebay.com',
28 'http://bing.com',
29 ]
30 20
31 21 class MemoryMeasuringPage(page_module.Page):
32 class MemoryHealthPage(page_module.Page): 22 """Abstract class for measuring memory on a story unit."""
33 """Abstract page class for measuring memory."""
34 23
35 _PHASE = NotImplemented 24 _PHASE = NotImplemented
36 25
37 def __init__(self, story_set, name, url): 26 def __init__(self, story_set, name, url):
38 super(MemoryHealthPage, self).__init__( 27 super(MemoryMeasuringPage, self).__init__(
39 page_set=story_set, name=name, url=url, 28 page_set=story_set, name=name, url=url,
40 shared_page_state_class=shared_page_state.SharedMobilePageState, 29 shared_page_state_class=shared_page_state.SharedMobilePageState,
41 grouping_keys={'phase': self._PHASE}) 30 grouping_keys={'phase': self._PHASE})
42 31
43 def _TakeMemoryMeasurement(self, action_runner): 32 def _TakeMemoryMeasurement(self, action_runner):
33 platform = action_runner.tab.browser.platform
44 action_runner.Wait(1) # See crbug.com/540022#c17. 34 action_runner.Wait(1) # See crbug.com/540022#c17.
35 if not platform.tracing_controller.is_tracing_running:
36 return # Tracing is not running, e.g., when recording a WPR archive.
perezju 2016/04/29 12:58:06 This allows to wpr recordings directly on the benc
sullivan 2016/04/29 13:31:44 Should there be some log warning/error here? IIUC,
perezju 2016/05/24 14:03:42 Done. Added a warning message.
45 with action_runner.CreateInteraction(self._PHASE): 37 with action_runner.CreateInteraction(self._PHASE):
46 action_runner.Wait(DUMP_WAIT_TIME) 38 action_runner.Wait(DUMP_WAIT_TIME)
47 action_runner.ForceGarbageCollection() 39 action_runner.ForceGarbageCollection()
48 action_runner.tab.browser.platform.FlushEntireSystemCache() 40 platform.FlushEntireSystemCache()
49 action_runner.Wait(DUMP_WAIT_TIME) 41 action_runner.Wait(DUMP_WAIT_TIME)
50 if not action_runner.tab.browser.DumpMemory(): 42 if not action_runner.tab.browser.DumpMemory():
51 logging.error('Unable to get a memory dump for %s.', self.name) 43 logging.error('Unable to get a memory dump for %s.', self.name)
52 44
53 45
54 class ForegroundPage(MemoryHealthPage): 46 class ForegroundPage(MemoryMeasuringPage):
55 """Take a measurement after loading a regular webpage.""" 47 """Take a measurement after loading a regular webpage."""
56 48
57 _PHASE = 'foreground' 49 _PHASE = 'foreground'
58 50
59 def __init__(self, story_set, name, url): 51 def __init__(self, story_set, name, url):
60 super(ForegroundPage, self).__init__(story_set, name, url) 52 super(ForegroundPage, self).__init__(story_set, name, url)
61 53
62 def RunPageInteractions(self, action_runner): 54 def RunPageInteractions(self, action_runner):
63 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 55 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
64 self._TakeMemoryMeasurement(action_runner) 56 self._TakeMemoryMeasurement(action_runner)
65 57
66 58
67 class BackgroundPage(MemoryHealthPage): 59 class BackgroundPage(MemoryMeasuringPage):
68 """Take a measurement while Chrome is in the background.""" 60 """Take a measurement while Chrome is in the background."""
69 61
70 _PHASE = 'background' 62 _PHASE = 'background'
71 63
72 def __init__(self, story_set, name): 64 def __init__(self, story_set, name):
73 super(BackgroundPage, self).__init__(story_set, name, 'about:blank') 65 super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
74 66
75 def RunPageInteractions(self, action_runner): 67 def RunPageInteractions(self, action_runner):
76 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 68 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
77 69
78 # Launch clock app, pushing Chrome to the background. 70 # Launch clock app, pushing Chrome to the background.
79 android_platform = action_runner.tab.browser.platform 71 android_platform = action_runner.tab.browser.platform
80 android_platform.LaunchAndroidApplication( 72 android_platform.LaunchAndroidApplication(
81 intent.Intent(package='com.google.android.deskclock', 73 intent.Intent(package='com.google.android.deskclock',
82 activity='com.android.deskclock.DeskClock'), 74 activity='com.android.deskclock.DeskClock'),
83 app_has_webviews=False) 75 app_has_webviews=False)
84 76
85 # Take measurement. 77 # Take measurement.
86 self._TakeMemoryMeasurement(action_runner) 78 self._TakeMemoryMeasurement(action_runner)
87 79
88 # Go back to Chrome. 80 # Go back to Chrome.
89 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK) 81 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
90 82
91 83
92 class MemoryHealthStory(story.StorySet): 84 class MemoryTop10Mobile(story.StorySet):
93 """User story for the Memory Health Plan.""" 85 """User story to measure foreground/background memory in top 10 mobile."""
94 86
95 def __init__(self): 87 def __init__(self):
96 super(MemoryHealthStory, self).__init__( 88 super(MemoryTop10Mobile, self).__init__(
97 archive_data_file='data/memory_health_plan.json', 89 archive_data_file='data/memory_top_10_mobile.json',
98 cloud_storage_bucket=story.PARTNER_BUCKET) 90 cloud_storage_bucket=story.PARTNER_BUCKET)
99 91
100 for url in URL_LIST: 92 for url in top_10_mobile.URL_LIST:
101 # We name pages so their foreground/background counterparts are easy 93 # We name pages so their foreground/background counterparts are easy
102 # to identify. For example 'http://google.com' becomes 94 # to identify. For example 'http://google.com' becomes
103 # 'http_google_com' and 'after_http_google_com' respectively. 95 # 'http_google_com' and 'after_http_google_com' respectively.
104 name = re.sub('\W+', '_', url) 96 name = re.sub('\W+', '_', url)
105 self.AddStory(ForegroundPage(self, name, url)) 97 self.AddStory(ForegroundPage(self, name, url))
106 self.AddStory(BackgroundPage(self, 'after_' + name)) 98 self.AddStory(BackgroundPage(self, 'after_' + name))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698