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

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

Issue 2006223008: Reland of Memory Infra: Replace memory_health_plan with top_10_mobile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep old benchmark name Created 4 years, 6 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
(Empty)
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
3 # found in the LICENSE file.
4
5 import logging
6 import re
7
8 from telemetry.page import page as page_module
9 from telemetry.page import shared_page_state
10 from telemetry import story
11
12 from devil.android.sdk import intent # pylint: disable=import-error
13 from devil.android.sdk import keyevent # pylint: disable=import-error
14
15
16 DUMP_WAIT_TIME = 3
17
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
31
32 class MemoryHealthPage(page_module.Page):
33 """Abstract page class for measuring memory."""
34
35 _PHASE = NotImplemented
36
37 def __init__(self, story_set, name, url):
38 super(MemoryHealthPage, self).__init__(
39 page_set=story_set, name=name, url=url,
40 shared_page_state_class=shared_page_state.SharedMobilePageState,
41 grouping_keys={'phase': self._PHASE})
42
43 def _TakeMemoryMeasurement(self, action_runner):
44 action_runner.Wait(1) # See crbug.com/540022#c17.
45 with action_runner.CreateInteraction(self._PHASE):
46 action_runner.Wait(DUMP_WAIT_TIME)
47 action_runner.ForceGarbageCollection()
48 action_runner.tab.browser.platform.FlushEntireSystemCache()
49 action_runner.Wait(DUMP_WAIT_TIME)
50 if not action_runner.tab.browser.DumpMemory():
51 logging.error('Unable to get a memory dump for %s.', self.name)
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
62 def RunPageInteractions(self, action_runner):
63 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
64 self._TakeMemoryMeasurement(action_runner)
65
66
67 class BackgroundPage(MemoryHealthPage):
68 """Take a measurement while Chrome is in the background."""
69
70 _PHASE = 'background'
71
72 def __init__(self, story_set, name):
73 super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
74
75 def RunPageInteractions(self, action_runner):
76 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
77
78 # Launch clock app, pushing Chrome to the background.
79 android_platform = action_runner.tab.browser.platform
80 android_platform.LaunchAndroidApplication(
81 intent.Intent(package='com.google.android.deskclock',
82 activity='com.android.deskclock.DeskClock'),
83 app_has_webviews=False)
84
85 # Take measurement.
86 self._TakeMemoryMeasurement(action_runner)
87
88 # Go back to Chrome.
89 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
90
91
92 class MemoryHealthStory(story.StorySet):
93 """User story for the Memory Health Plan."""
94
95 def __init__(self):
96 super(MemoryHealthStory, self).__init__(
97 archive_data_file='data/memory_health_plan.json',
98 cloud_storage_bucket=story.PARTNER_BUCKET)
99
100 for url in URL_LIST:
101 # We name pages so their foreground/background counterparts are easy
102 # to identify. For example 'http://google.com' becomes
103 # 'http_google_com' and 'after_http_google_com' respectively.
104 name = re.sub('\W+', '_', url)
105 self.AddStory(ForegroundPage(self, name, url))
106 self.AddStory(BackgroundPage(self, 'after_' + name))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698