Commit bac49d5c authored by petrcermak's avatar petrcermak Committed by Commit bot

[system-health] Add support for recording stories directly through story set

Until now, System Health stories had to be recorded through a benchmark,
e.g. system_health.memory_*:

  tools/perf/record_wpr mobile_memory_system_health
  tools/perf/record_wpr desktop_memory_system_health

This goes against the idea of SH stories being reusable across multiple
benchmarks. Instead, it is now possible (and recommended) to record
directly through the story set:

  tools/perf/record_wpr mobile_system_health_story_set
  tools/perf/record_wpr desktop_system_health_story_set

This will ensure that all SH stories are recorded under the same
conditions (10s wait at the end of the story without a memory dump).

BUG=589726

Review-Url: https://codereview.chromium.org/2276943002
Cr-Commit-Position: refs/heads/master@{#414373}
parent 2c33a82e
...@@ -31,6 +31,32 @@ class SystemHealthStorySet(story.StorySet): ...@@ -31,6 +31,32 @@ class SystemHealthStorySet(story.StorySet):
self.AddStory(story_class(self, take_memory_measurement)) self.AddStory(story_class(self, take_memory_measurement))
class DesktopSystemHealthStorySet(SystemHealthStorySet):
"""Desktop user stories for the System Health Plan.
Note: This story set is only intended to be used for recording stories via
tools/perf/record_wpr. If you would like to use it in a benchmark, please use
the generic SystemHealthStorySet class instead (you'll need to override the
CreateStorySet method of your benchmark).
"""
def __init__(self):
super(DesktopSystemHealthStorySet, self).__init__(
'desktop', take_memory_measurement=False)
class MobileSystemHealthStorySet(SystemHealthStorySet):
"""Mobile user stories for the System Health Plan.
Note: This story set is only intended to be used for recording stories via
tools/perf/record_wpr. If you would like to use it in a benchmark, please use
the generic SystemHealthStorySet class instead (you'll need to override the
CreateStorySet method of your benchmark).
"""
def __init__(self):
super(MobileSystemHealthStorySet, self).__init__(
'mobile', take_memory_measurement=False)
def _IterAllSystemHealthStoryClasses(): def _IterAllSystemHealthStoryClasses():
start_dir = os.path.dirname(os.path.abspath(__file__)) start_dir = os.path.dirname(os.path.abspath(__file__))
# Sort the classes by their names so that their order is stable and # Sort the classes by their names so that their order is stable and
......
...@@ -47,25 +47,11 @@ class SystemHealthStory(page.Page): ...@@ -47,25 +47,11 @@ class SystemHealthStory(page.Page):
self._take_memory_measurement = take_memory_measurement self._take_memory_measurement = take_memory_measurement
def _Measure(self, action_runner): def _Measure(self, action_runner):
if self._ShouldMeasureMemory(action_runner): if self._take_memory_measurement:
action_runner.MeasureMemory(deterministic_mode=True) action_runner.MeasureMemory(deterministic_mode=True)
else: else:
action_runner.Wait(_WAIT_TIME_AFTER_LOAD) action_runner.Wait(_WAIT_TIME_AFTER_LOAD)
def _ShouldMeasureMemory(self, action_runner):
if not self._take_memory_measurement:
return False
# The check below is also performed in action_runner.MeasureMemory().
# However, we need to duplicate it here so that the story would wait for
# |_WAIT_TIME_AFTER_LOAD| seconds after load when recorded via the
# system_health.memory_* benchmarks.
# TODO(petrcermak): Make it possible (and mandatory) to record the story
# directly through the story set and remove this check.
tracing_controller = action_runner.tab.browser.platform.tracing_controller
if not tracing_controller.is_tracing_running:
return False # Tracing is not running, e.g. when recording a WPR archive.
return True
def _Login(self, action_runner): def _Login(self, action_runner):
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment