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

Unified Diff: tools/perf/page_sets/memory_health_story.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, 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/page_sets/memory_health_story.py
diff --git a/tools/perf/page_sets/memory_health_story.py b/tools/perf/page_sets/memory_health_story.py
new file mode 100644
index 0000000000000000000000000000000000000000..0bd52362c1885115c93e370c53db58a14d0a41b7
--- /dev/null
+++ b/tools/perf/page_sets/memory_health_story.py
@@ -0,0 +1,106 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import re
+
+from telemetry.page import page as page_module
+from telemetry.page import shared_page_state
+from telemetry import story
+
+from devil.android.sdk import intent # pylint: disable=import-error
+from devil.android.sdk import keyevent # pylint: disable=import-error
+
+
+DUMP_WAIT_TIME = 3
+
+URL_LIST = [
+ 'http://google.com',
+ 'http://vimeo.com',
+ 'http://yahoo.com',
+ 'http://baidu.com',
+ 'http://cnn.com',
+ 'http://yandex.ru',
+ 'http://yahoo.co.jp',
+ 'http://amazon.com',
+ 'http://ebay.com',
+ 'http://bing.com',
+]
+
+
+class MemoryHealthPage(page_module.Page):
+ """Abstract page class for measuring memory."""
+
+ _PHASE = NotImplemented
+
+ def __init__(self, story_set, name, url):
+ super(MemoryHealthPage, self).__init__(
+ page_set=story_set, name=name, url=url,
+ shared_page_state_class=shared_page_state.SharedMobilePageState,
+ grouping_keys={'phase': self._PHASE})
+
+ def _TakeMemoryMeasurement(self, action_runner):
+ action_runner.Wait(1) # See crbug.com/540022#c17.
+ with action_runner.CreateInteraction(self._PHASE):
+ action_runner.Wait(DUMP_WAIT_TIME)
+ action_runner.ForceGarbageCollection()
+ action_runner.tab.browser.platform.FlushEntireSystemCache()
+ action_runner.Wait(DUMP_WAIT_TIME)
+ if not action_runner.tab.browser.DumpMemory():
+ logging.error('Unable to get a memory dump for %s.', self.name)
+
+
+class ForegroundPage(MemoryHealthPage):
+ """Take a measurement after loading a regular webpage."""
+
+ _PHASE = 'foreground'
+
+ def __init__(self, story_set, name, url):
+ super(ForegroundPage, self).__init__(story_set, name, url)
+
+ def RunPageInteractions(self, action_runner):
+ action_runner.tab.WaitForDocumentReadyStateToBeComplete()
+ self._TakeMemoryMeasurement(action_runner)
+
+
+class BackgroundPage(MemoryHealthPage):
+ """Take a measurement while Chrome is in the background."""
+
+ _PHASE = 'background'
+
+ def __init__(self, story_set, name):
+ super(BackgroundPage, self).__init__(story_set, name, 'about:blank')
+
+ def RunPageInteractions(self, action_runner):
+ action_runner.tab.WaitForDocumentReadyStateToBeComplete()
+
+ # Launch clock app, pushing Chrome to the background.
+ android_platform = action_runner.tab.browser.platform
+ android_platform.LaunchAndroidApplication(
+ intent.Intent(package='com.google.android.deskclock',
+ activity='com.android.deskclock.DeskClock'),
+ app_has_webviews=False)
+
+ # Take measurement.
+ self._TakeMemoryMeasurement(action_runner)
+
+ # Go back to Chrome.
+ android_platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_BACK)
+
+
+class MemoryHealthStory(story.StorySet):
+ """User story for the Memory Health Plan."""
+
+ def __init__(self):
+ super(MemoryHealthStory, self).__init__(
+ archive_data_file='data/memory_health_plan.json',
+ cloud_storage_bucket=story.PARTNER_BUCKET)
+
+ for url in URL_LIST:
+ # We name pages so their foreground/background counterparts are easy
+ # to identify. For example 'http://google.com' becomes
+ # 'http_google_com' and 'after_http_google_com' respectively.
+ name = re.sub('\W+', '_', url)
+ self.AddStory(ForegroundPage(self, name, url))
+ self.AddStory(BackgroundPage(self, 'after_' + name))
« no previous file with comments | « tools/perf/page_sets/data/memory_top_10_mobile_000.wpr.sha1 ('k') | tools/perf/page_sets/memory_top_10_mobile.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698