Index: tools/perf/page_sets/system_health/system_health_stories.py |
diff --git a/tools/perf/page_sets/system_health/system_health_stories.py b/tools/perf/page_sets/system_health/system_health_stories.py |
index 569d5c01d4973eaa83f5cd059c0bcc1e694d9f49..9b738934462daaed101349e787c4f4166e5e5a17 100644 |
--- a/tools/perf/page_sets/system_health/system_health_stories.py |
+++ b/tools/perf/page_sets/system_health/system_health_stories.py |
@@ -2,35 +2,46 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import re |
+import os |
+ |
from page_sets.system_health import platforms |
-from page_sets.system_health import loading_stories |
+from page_sets.system_health import system_health_story |
from telemetry import story |
+from telemetry.core import discover |
-class _SystemHealthStorySet(story.StorySet): |
+class SystemHealthStorySet(story.StorySet): |
"""User stories for the System Health Plan. |
See https://goo.gl/Jek2NL. |
""" |
- PLATFORM = NotImplemented |
- |
- def __init__(self, take_memory_measurement=True): |
- super(_SystemHealthStorySet, self).__init__( |
- archive_data_file=('../data/memory_system_health_%s.json' % |
- self.PLATFORM), |
+ def __init__(self, platform, story_name_regex=r'.*', |
nednguyen
2016/07/14 20:01:49
this story_name_regex is a bit too flexible. I thi
petrcermak
2016/07/15 09:01:43
Done. Note that this means that whenever we add a
nednguyen
2016/07/15 10:48:29
If it's relevant to browsing, why can't they name
|
+ take_memory_measurement=False): |
+ super(SystemHealthStorySet, self).__init__( |
+ archive_data_file=('../data/memory_system_health_%s.json' % platform), |
cloud_storage_bucket=story.PARTNER_BUCKET) |
- for story_class in loading_stories.IterAllStoryClasses(): |
- if self.PLATFORM not in story_class.SUPPORTED_PLATFORMS: |
- continue |
- self.AddStory(story_class(self, take_memory_measurement)) |
+ assert platform in platforms.ALL_PLATFORMS |
-class DesktopSystemHealthStorySet(_SystemHealthStorySet): |
- """Desktop user stories for Chrome System Health Plan.""" |
- PLATFORM = platforms.DESKTOP |
+ if isinstance(story_name_regex, basestring): |
+ story_name_regex = re.compile(story_name_regex) |
+ |
+ for story_class in _IterAllSystemHealthStoryClasses(): |
+ if (story_class.ABSTRACT_STORY or |
+ platform not in story_class.SUPPORTED_PLATFORMS or |
+ not story_name_regex.match(story_class.NAME)): |
+ continue |
+ self.AddStory(story_class(self, take_memory_measurement)) |
-class MobileSystemHealthStorySet(_SystemHealthStorySet): |
- """Mobile user stories for Chrome System Health Plan.""" |
- PLATFORM = platforms.MOBILE |
+def _IterAllSystemHealthStoryClasses(): |
+ start_dir = os.path.dirname(os.path.abspath(__file__)) |
+ # Sort the classes by their names so that their order is stable and |
+ # deterministic. |
+ for unused_cls_name, cls in sorted(discover.DiscoverClasses( |
+ start_dir=start_dir, |
+ top_level_dir=os.path.dirname(start_dir), |
+ base_class=system_health_story.SystemHealthStory).iteritems()): |
+ yield cls |