Chromium Code Reviews| Index: tools/perf/page_sets/system_health/multi_tab_stories.py |
| diff --git a/tools/perf/page_sets/system_health/multi_tab_stories.py b/tools/perf/page_sets/system_health/multi_tab_stories.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..21cc4498ad5ae635c999c8fc847e4e05dcfcd16b |
| --- /dev/null |
| +++ b/tools/perf/page_sets/system_health/multi_tab_stories.py |
| @@ -0,0 +1,175 @@ |
| +# Copyright 2017 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 json |
| +import py_utils |
| +import logging |
| + |
| +from telemetry.value import histogram_util |
| +from page_sets.system_health import system_health_story |
| +from page_sets.system_health import platforms |
| + |
| + |
| +class _MultiTabStory(system_health_story.SystemHealthStory): |
| + ABSTRACT_STORY = True |
| + def __init__(self, story_set, take_memory_measurement): |
| + self.URL = self.URL_LIST[0] |
| + super(_MultiTabStory, self).__init__(story_set, take_memory_measurement) |
| + self._tabs = None |
| + self._prev_histogram = None |
| + |
| + @classmethod |
| + def _GetTabSwitchHistogram(cls, tab_to_switch): |
| + histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
| + histogram_type = histogram_util.BROWSER_HISTOGRAM |
| + return histogram_util.GetHistogram( |
| + histogram_type, histogram_name, tab_to_switch) |
| + |
| + def _WaitTabSwitchComplete(self, tab_to_switch): |
| + def _IsDone(): |
| + # pylint: disable=W0640 |
|
eakuefner
2017/03/01 16:52:13
nit: please write out the name of the rule you're
vovoy
2017/03/02 09:30:27
Removed this function in the next patch.
|
| + cur_histogram = self._GetTabSwitchHistogram(tab_to_switch) |
| + diff_histogram = histogram_util.SubtractHistogram( |
| + cur_histogram, self._prev_histogram) |
| + # TODO(deanliao): Add SubtractHistogramRawValue to process histogram |
| + # object instead of JSON string. |
| + diff_histogram_count = json.loads(diff_histogram).get('count', 0) |
| + return diff_histogram_count > 0 |
| + py_utils.WaitFor(_IsDone, 30) |
| + |
| + # We need to get histogram again instead of getting cur_histogram as |
| + # variables modified inside inner function cannot be retrieved. However, |
| + # inner function can see external scope's variables. |
| + self._prev_histogram = self._GetTabSwitchHistogram(tab_to_switch) |
| + |
| + def RunNavigateSteps(self, action_runner): |
| + super(_MultiTabStory, self).RunNavigateSteps(action_runner) |
| + |
| + # create tabs |
|
eakuefner
2017/03/01 16:52:13
nit: this comment seems unnecessary because it rep
vovoy
2017/03/02 09:30:27
Done.
|
| + browser = action_runner.tab.browser |
| + self._tabs = [action_runner.tab] |
| + |
| + for i in range(1, len(self.URL_LIST)): |
| + new_tab = browser.tabs.New() |
| + self._tabs.append(new_tab) |
| + new_tab.action_runner.Navigate(self.URL_LIST[i]) |
| + |
| + for i in range(len(self.URL_LIST)): |
| + try: |
| + py_utils.WaitFor(self._tabs[i].HasReachedQuiescence, 15) |
| + except py_utils.TimeoutException: |
| + logging.warning('HasReachedQuiescence timeout, url[%d]: %s' |
| + % (i, self.URL_LIST[i])) |
| + |
| + def RunPageInteractions(self, action_runner): |
| + # get initial histogram |
| + self._prev_histogram = self._GetTabSwitchHistogram(self._tabs[-1]) |
| + |
| + # tab switching |
| + for i in range(len(self._tabs)): |
| + self._tabs[i].Activate() |
| + self._WaitTabSwitchComplete(self._tabs[i]) |
| + |
| + |
| +class MultiTabTypical24Story(_MultiTabStory): |
| + NAME = 'multitab:typical24:typical24' |
| + URL_LIST = [ |
| + # Why: Alexa games #48 |
| + 'http://www.nick.com/games', |
| + # Why: Alexa sports #45 |
| + 'http://www.rei.com/', |
| + # Why: Alexa sports #50 |
| + 'http://www.fifa.com/', |
| + # Why: Alexa shopping #41 |
| + 'http://www.gamestop.com/ps3', |
| + # Why: Alexa news #55 |
| + ('http://www.economist.com/news/science-and-technology/21573529-small-' |
| + 'models-cosmic-phenomena-are-shedding-light-real-thing-how-build'), |
| + # Why: Alexa news #67 |
| + 'http://www.theonion.com', |
| + 'http://arstechnica.com/', |
| + # Why: Alexa home #10 |
| + 'http://allrecipes.com/Recipe/Pull-Apart-Hot-Cross-Buns/Detail.aspx', |
| + 'http://www.html5rocks.com/en/', |
| + 'http://www.mlb.com/', |
| + 'http://gawker.com/5939683/based-on-a-true-story-is-a-rotten-lie-i-hope-you-never-believe', |
| + 'http://www.imdb.com/title/tt0910970/', |
| + 'http://www.flickr.com/search/?q=monkeys&f=hp', |
| + 'http://money.cnn.com/', |
| + 'http://www.nationalgeographic.com/', |
| + 'http://premierleague.com', |
| + 'http://www.osubeavers.com/', |
| + 'http://walgreens.com', |
| + 'http://colorado.edu', |
| + ('http://www.ticketmaster.com/JAY-Z-and-Justin-Timberlake-tickets/artist/' |
| + '1837448?brand=none&tm_link=tm_homeA_rc_name2'), |
| + # pylint: disable=line-too-long |
| + 'http://www.theverge.com/2013/3/5/4061684/inside-ted-the-smartest-bubble-in-the-world', |
| + 'http://www.airbnb.com/', |
| + 'http://www.ign.com/', |
| + # Why: Alexa health #25 |
| + 'http://www.fda.gov', |
| + ] |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| +class MultiTabFiveBlankPagesStory(_MultiTabStory): |
| + NAME = 'multitab:blanks:blanks' |
| + URL_LIST = [ |
| + 'about:blank', |
| + 'about:blank', |
| + 'about:blank', |
| + 'about:blank', |
| + 'about:blank', |
| + ] |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + |
| +class MultiTabTop9Story(_MultiTabStory): |
| + NAME = 'multitab:top9:top9' |
| + URL_LIST = [ |
| + 'https://www.google.com/#hl=en&q=barack+obama', |
| + 'https://www.google.com/calendar/', |
| + 'http://www.youtube.com', |
| + 'https://www.facebook.com/barackobama', |
| + 'http://en.wikipedia.org/wiki/Wikipedia', |
| + 'http://www.amazon.com', |
| + 'http://www.yahoo.com/', |
| + 'http://www.bing.com/', |
| + 'http://www.ask.com/' |
| + ] |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + |
| +class MultiTabToughImageCasesStory(_MultiTabStory): |
| + NAME = 'multitab:toughimage:toughimage' |
| + URL_LIST = [ |
| + ('https://upload.wikimedia.org/wikipedia/commons/b/b3/' |
| + 'KC-130_performs_mid-air_refueling_over_Beaufort_150319-' |
| + 'M-ZZ999-306.jpg'), |
| + ('http://upload.wikimedia.org/wikipedia/commons/c/cb/' |
| + 'General_history%2C_Alaska_Yukon_Pacific_Exposition%' |
| + '2C_fully_illustrated_-_meet_me_in_Seattle_1909_-_Page_78.jpg') |
| + ] |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + |
| + |
| +class MultiTabToughEnergyCasesStory(_MultiTabStory): |
| + NAME = 'multitab:toughenergy:toughenergy' |
| + URL_LIST = [ |
| + 'http://codepen.io/testificate364/full/nrbDc', |
| + 'http://codepen.io/testificate364/full/fhKCg', |
| + 'http://codepen.io/testificate364/full/paJhg', |
| + 'http://codepen.io/testificate364/full/yaosK', |
| + 'http://codepen.io/testificate364/full/DLbxg', |
| + 'http://codepen.io/testificate364/full/kFvpd', |
| + 'http://codepen.io/testificate364/full/lEhyw', |
| + 'http://codepen.io/testificate364/full/zhgBD', |
| + 'http://codepen.io/testificate364/full/jetyn', |
| + 'http://codepen.io/testificate364/full/Kvdxs', |
| + 'http://codepen.io/testificate364/full/lJAiH', |
| + 'http://codepen.io/testificate364/full/EFceH', |
| + 'http://codepen.io/testificate364/full/slBue', |
| + 'http://codepen.io/testificate364/full/HdIgr', |
| + ] |
| + SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |