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

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

Issue 1920363003: Reland of Set up a parallel memory.memory_health_quick_tbmv2 benchmark (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
« no previous file with comments | « tools/perf/benchmarks/memory_infra.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 11 matching lines...) Expand all
22 'http://baidu.com', 22 'http://baidu.com',
23 'http://cnn.com', 23 'http://cnn.com',
24 'http://yandex.ru', 24 'http://yandex.ru',
25 'http://yahoo.co.jp', 25 'http://yahoo.co.jp',
26 'http://amazon.com', 26 'http://amazon.com',
27 'http://ebay.com', 27 'http://ebay.com',
28 'http://bing.com', 28 'http://bing.com',
29 ] 29 ]
30 30
31 31
32 class ForegroundPage(page_module.Page): 32 class MemoryHealthPage(page_module.Page):
33 """Take a measurement after loading a regular webpage.""" 33 """Abstract page class for measuring memory."""
34
35 _PHASE = NotImplemented
34 36
35 def __init__(self, story_set, name, url): 37 def __init__(self, story_set, name, url):
36 super(ForegroundPage, self).__init__( 38 super(MemoryHealthPage, self).__init__(
37 url=url, page_set=story_set, name=name, 39 page_set=story_set, name=name, url=url,
38 shared_page_state_class=shared_page_state.SharedMobilePageState) 40 shared_page_state_class=shared_page_state.SharedMobilePageState,
41 grouping_keys={'phase': self._PHASE})
39 42
40 def _TakeMemoryMeasurement(self, action_runner, phase): 43 def _TakeMemoryMeasurement(self, action_runner):
41 action_runner.Wait(1) # See crbug.com/540022#c17. 44 action_runner.Wait(1) # See crbug.com/540022#c17.
42 with action_runner.CreateInteraction(phase): 45 with action_runner.CreateInteraction(self._PHASE):
43 action_runner.Wait(DUMP_WAIT_TIME) 46 action_runner.Wait(DUMP_WAIT_TIME)
44 action_runner.ForceGarbageCollection() 47 action_runner.ForceGarbageCollection()
45 action_runner.tab.browser.platform.FlushEntireSystemCache() 48 action_runner.tab.browser.platform.FlushEntireSystemCache()
46 action_runner.Wait(DUMP_WAIT_TIME) 49 action_runner.Wait(DUMP_WAIT_TIME)
47 if not action_runner.tab.browser.DumpMemory(): 50 if not action_runner.tab.browser.DumpMemory():
48 logging.error('Unable to get a memory dump for %s.', self.name) 51 logging.error('Unable to get a memory dump for %s.', self.name)
49 52
53
54 class ForegroundPage(MemoryHealthPage):
55 """Take a measurement after loading a regular webpage."""
56
57 _PHASE = 'foreground'
58
59 def __init__(self, story_set, name, url):
60 super(ForegroundPage, self).__init__(story_set, name, url)
61
50 def RunPageInteractions(self, action_runner): 62 def RunPageInteractions(self, action_runner):
51 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 63 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
52 self._TakeMemoryMeasurement(action_runner, 'foreground') 64 self._TakeMemoryMeasurement(action_runner)
53 65
54 66
55 class BackgroundPage(ForegroundPage): 67 class BackgroundPage(MemoryHealthPage):
56 """Take a measurement while Chrome is in the background.""" 68 """Take a measurement while Chrome is in the background."""
57 69
70 _PHASE = 'background'
71
58 def __init__(self, story_set, name): 72 def __init__(self, story_set, name):
59 super(BackgroundPage, self).__init__(story_set, name, 'about:blank') 73 super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
60 74
61 def RunPageInteractions(self, action_runner): 75 def RunPageInteractions(self, action_runner):
62 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 76 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
63 77
64 # Launch clock app, pushing Chrome to the background. 78 # Launch clock app, pushing Chrome to the background.
65 android_platform = action_runner.tab.browser.platform 79 android_platform = action_runner.tab.browser.platform
66 android_platform.LaunchAndroidApplication( 80 android_platform.LaunchAndroidApplication(
67 intent.Intent(package='com.google.android.deskclock', 81 intent.Intent(package='com.google.android.deskclock',
68 activity='com.android.deskclock.DeskClock'), 82 activity='com.android.deskclock.DeskClock'),
69 app_has_webviews=False) 83 app_has_webviews=False)
70 84
71 # Take measurement. 85 # Take measurement.
72 self._TakeMemoryMeasurement(action_runner, 'background') 86 self._TakeMemoryMeasurement(action_runner)
73 87
74 # Go back to Chrome. 88 # Go back to Chrome.
75 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK) 89 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
76 90
77 91
78 class MemoryHealthStory(story.StorySet): 92 class MemoryHealthStory(story.StorySet):
79 """User story for the Memory Health Plan.""" 93 """User story for the Memory Health Plan."""
80 94
81 def __init__(self): 95 def __init__(self):
82 super(MemoryHealthStory, self).__init__( 96 super(MemoryHealthStory, self).__init__(
83 archive_data_file='data/memory_health_plan.json', 97 archive_data_file='data/memory_health_plan.json',
84 cloud_storage_bucket=story.PARTNER_BUCKET) 98 cloud_storage_bucket=story.PARTNER_BUCKET)
85 99
86 for url in URL_LIST: 100 for url in URL_LIST:
87 # We name pages so their foreground/background counterparts are easy 101 # We name pages so their foreground/background counterparts are easy
88 # to identify. For example 'http://google.com' becomes 102 # to identify. For example 'http://google.com' becomes
89 # 'http_google_com' and 'after_http_google_com' respectively. 103 # 'http_google_com' and 'after_http_google_com' respectively.
90 name = re.sub('\W+', '_', url) 104 name = re.sub('\W+', '_', url)
91 self.AddStory(ForegroundPage(self, name, url)) 105 self.AddStory(ForegroundPage(self, name, url))
92 self.AddStory(BackgroundPage(self, 'after_' + name)) 106 self.AddStory(BackgroundPage(self, 'after_' + name))
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/memory_infra.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698