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

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

Issue 2007113009: Revert of 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, 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
« no previous file with comments | « tools/perf/page_sets/memory_health_story.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
(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 from page_sets import top_10_mobile
16
17
18 DUMP_WAIT_TIME = 3
19
20
21 class MemoryMeasurementPage(page_module.Page):
22 """Abstract class for measuring memory on a story unit."""
23
24 _PHASE = NotImplemented
25
26 def __init__(self, story_set, name, url):
27 super(MemoryMeasurementPage, self).__init__(
28 page_set=story_set, name=name, url=url,
29 shared_page_state_class=shared_page_state.SharedMobilePageState,
30 grouping_keys={'phase': self._PHASE})
31
32 def _TakeMemoryMeasurement(self, action_runner):
33 platform = action_runner.tab.browser.platform
34 action_runner.Wait(1) # See crbug.com/540022#c17.
35 if not platform.tracing_controller.is_tracing_running:
36 logging.warning('Tracing is off. No memory dumps are being recorded.')
37 return # Tracing is not running, e.g., when recording a WPR archive.
38 with action_runner.CreateInteraction(self._PHASE):
39 action_runner.Wait(DUMP_WAIT_TIME)
40 action_runner.ForceGarbageCollection()
41 platform.FlushEntireSystemCache()
42 action_runner.Wait(DUMP_WAIT_TIME)
43 if not action_runner.tab.browser.DumpMemory():
44 logging.error('Unable to get a memory dump for %s.', self.name)
45
46
47 class ForegroundPage(MemoryMeasurementPage):
48 """Take a measurement after loading a regular webpage."""
49
50 _PHASE = 'foreground'
51
52 def __init__(self, story_set, name, url):
53 super(ForegroundPage, self).__init__(story_set, name, url)
54
55 def RunPageInteractions(self, action_runner):
56 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
57 self._TakeMemoryMeasurement(action_runner)
58
59
60 class BackgroundPage(MemoryMeasurementPage):
61 """Take a measurement while Chrome is in the background."""
62
63 _PHASE = 'background'
64
65 def __init__(self, story_set, name):
66 super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
67
68 def RunPageInteractions(self, action_runner):
69 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
70
71 # Launch clock app, pushing Chrome to the background.
72 android_platform = action_runner.tab.browser.platform
73 android_platform.LaunchAndroidApplication(
74 intent.Intent(package='com.google.android.deskclock',
75 activity='com.android.deskclock.DeskClock'),
76 app_has_webviews=False)
77
78 # Take measurement.
79 self._TakeMemoryMeasurement(action_runner)
80
81 # Go back to Chrome.
82 android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
83
84
85 class MemoryTop10Mobile(story.StorySet):
86 """User story to measure foreground/background memory in top 10 mobile."""
87
88 def __init__(self):
89 super(MemoryTop10Mobile, self).__init__(
90 archive_data_file='data/memory_top_10_mobile.json',
91 cloud_storage_bucket=story.PARTNER_BUCKET)
92
93 for url in top_10_mobile.URL_LIST:
94 # We name pages so their foreground/background counterparts are easy
95 # to identify. For example 'http://google.com' becomes
96 # 'http_google_com' and 'after_http_google_com' respectively.
97 name = re.sub('\W+', '_', url)
98 self.AddStory(ForegroundPage(self, name, url))
99 self.AddStory(BackgroundPage(self, 'after_' + name))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/memory_health_story.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698