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

Side by Side Diff: tools/perf/page_sets/system_health/system_health_story.py

Issue 2118293002: Add benchmark that imitates news reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move stories to system health Created 4 years, 5 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 2016 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
7 from page_sets.system_health import platforms
8
9 from telemetry.core import discover
10 from telemetry.page import page
11
12
13 _DUMP_WAIT_TIME = 3
14
15
16 class SystemHealthStory(page.Page):
17 """Abstract base class for System Health user stories."""
18
19 # The full name of a single page story has the form CASE:GROUP:PAGE (e.g.
20 # 'load:search:google').
21 NAME = NotImplemented
22 URL = NotImplemented
23 SUPPORTED_PLATFORMS = platforms.ALL_PLATFORMS
24
25 def __init__(self, story_set, take_memory_measurement):
26 case, group, _ = self.NAME.split(':')
27 super(SystemHealthStory, self).__init__(
28 page_set=story_set, name=self.NAME, url=self.URL,
29 credentials_path='../data/credentials.json',
30 grouping_keys={'case': case, 'group': group})
31 self._take_memory_measurement = take_memory_measurement
32
33 def _Measure(self, action_runner):
34 if not self._take_memory_measurement:
35 return
36 # TODO(petrcermak): This method is essentially the same as
37 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py.
38 # Consider sharing the common code.
39 action_runner.Wait(_DUMP_WAIT_TIME)
40 action_runner.ForceGarbageCollection()
41 action_runner.Wait(_DUMP_WAIT_TIME)
42 tracing_controller = action_runner.tab.browser.platform.tracing_controller
43 if not tracing_controller.is_tracing_running:
44 return # Tracing is not running, e.g., when recording a WPR archive.
45 if not action_runner.tab.browser.DumpMemory():
46 logging.error('Unable to get a memory dump for %s.', self.name)
47
48 def _Login(self, action_runner):
49 pass
50
51 def _DidLoadDocument(self, action_runner):
52 pass
53
54 def RunNavigateSteps(self, action_runner):
55 self._Login(action_runner)
56 super(SystemHealthStory, self).RunNavigateSteps(action_runner)
57
58 def RunPageInteractions(self, action_runner):
59 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
60 self._DidLoadDocument(action_runner)
61 self._Measure(action_runner)
62
63
64 def IterAllStoryClasses(module, base_class):
65 # Sort the classes by their names so that their order is stable and
66 # deterministic.
67 for unused_cls_name, cls in sorted(discover.DiscoverClassesInModule(
68 module=module,
69 base_class=base_class,
70 index_by_class_name=True).iteritems()):
71 yield cls
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698