Chromium Code Reviews| Index: tools/perf/measurements/tab_switching.py |
| diff --git a/tools/perf/measurements/tab_switching.py b/tools/perf/measurements/tab_switching.py |
| index 41290dc07de244e293b794f3c951467bfae2d0d0..b6fa5414162b5fa3a32e6b76f929ae2c8993576c 100644 |
| --- a/tools/perf/measurements/tab_switching.py |
| +++ b/tools/perf/measurements/tab_switching.py |
| @@ -10,6 +10,7 @@ between when a tab was first requested to be shown, and when it was painted. |
| Power usage is also measured. |
| """ |
| +import optparse |
|
aiolos (Not reviewing)
2015/04/03 18:16:39
argparse should be used instead of optparse.
|
| import time |
| from metrics import power |
| @@ -30,6 +31,26 @@ class TabSwitching(page_test.PageTest): |
| self._first_page_in_pageset = True |
| self._power_metric = None |
| + @classmethod |
| + def AddCommandLineArgs(cls, parser): |
|
aiolos (Not reviewing)
2015/04/03 18:16:39
This shouldn't be specified via commandline arg.
|
| + group = optparse.OptionGroup(parser, 'Tab switching options') |
| + group.add_option('--cycle-count', |
| + dest='cycle_count', |
| + default=1, |
| + type='int', |
| + help='Number of times the tab set is cycled through.') |
| + # Use a high polling frequency throughout the test when checking for |
| + # completion of a tab switch. We may have to change this when running |
| + # in a VM instrumented to get memory access statistics, because of the |
| + # huge slowdown factor. |
| + group.add_option('--poll-interval', |
| + dest='poll_interval', |
| + default=0.1, |
| + type='float', |
| + help='Poll interval when checking for completion ' |
| + 'of a tab switch.') |
| + parser.add_option_group(group) |
| + |
| def CustomizeBrowserOptions(self, options): |
| options.AppendExtraBrowserArgs([ |
| '--enable-stats-collection-bindings' |
| @@ -77,18 +98,23 @@ class TabSwitching(page_test.PageTest): |
| histogram_type, histogram_name, tab) |
| prev_histogram = first_histogram |
| - for i in xrange(len(tab.browser.tabs)): |
| - t = tab.browser.tabs[i] |
| - t.Activate() |
| - def _IsDone(): |
| - cur_histogram = histogram_util.GetHistogram( |
| + for _ in xrange(self.options.cycle_count): |
| + for i in xrange(len(tab.browser.tabs)): |
| + t = tab.browser.tabs[i] |
| + t.Activate() |
| + def _IsDone(): |
| + cur_histogram = histogram_util.GetHistogram( |
| + histogram_type, histogram_name, tab) |
| + diff_histogram = histogram_util.SubtractHistogram( |
| + cur_histogram, prev_histogram) |
| + return diff_histogram.count != 0 |
| + # Use a fixed poll interval when detecting the completion of a |
| + # tab switch to reduce variance as the system gets slow, for |
| + # instance because of swapping. |
| + util.WaitFor( |
| + _IsDone, 30, fixed_poll_interval=self.options.poll_interval) |
| + prev_histogram = histogram_util.GetHistogram( |
| histogram_type, histogram_name, tab) |
| - diff_histogram = histogram_util.SubtractHistogram( |
| - cur_histogram, prev_histogram) |
| - return diff_histogram |
| - util.WaitFor(_IsDone, 30) |
| - prev_histogram = histogram_util.GetHistogram( |
| - histogram_type, histogram_name, tab) |
| last_histogram = histogram_util.GetHistogram( |
| histogram_type, histogram_name, tab) |