| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Multi tab memory test. | 5 """Multi tab memory test. |
| 6 | 6 |
| 7 This test is a multi tab test, but we're interested in measurements for | 7 This test is a multi tab test, but we're interested in measurements for |
| 8 the entire test rather than each single page. | 8 the entire test rather than each single page. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 from telemetry.page import page_test |
| 11 | 12 |
| 12 from metrics import memory | 13 from metrics import memory |
| 13 from telemetry.page import page_test | 14 |
| 14 | 15 |
| 15 class MemoryMultiTab(page_test.PageTest): | 16 class MemoryMultiTab(page_test.PageTest): |
| 16 def __init__(self): | 17 def __init__(self): |
| 17 super(MemoryMultiTab, self).__init__() | 18 super(MemoryMultiTab, self).__init__() |
| 18 self._memory_metric = None | 19 self._memory_metric = None |
| 19 # _first_tab is used to make memory measurements | 20 # _first_tab is used to make memory measurements |
| 20 self._first_tab = None | 21 self._first_tab = None |
| 21 | 22 |
| 22 def DidStartBrowser(self, browser): | 23 def DidStartBrowser(self, browser): |
| 23 self._memory_metric = memory.MemoryMetric(browser) | 24 self._memory_metric = memory.MemoryMetric(browser) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 # Start measurement on the first tab. | 36 # Start measurement on the first tab. |
| 36 if not self._first_tab: | 37 if not self._first_tab: |
| 37 self._memory_metric.Start(page, tab) | 38 self._memory_metric.Start(page, tab) |
| 38 self._first_tab = tab | 39 self._first_tab = tab |
| 39 | 40 |
| 40 def ValidateAndMeasurePage(self, page, tab, results): | 41 def ValidateAndMeasurePage(self, page, tab, results): |
| 41 # Finalize measurement on the last tab. | 42 # Finalize measurement on the last tab. |
| 42 if len(tab.browser.tabs) == len(page.page_set.pages): | 43 if len(tab.browser.tabs) == len(page.page_set.pages): |
| 43 self._memory_metric.Stop(page, self._first_tab) | 44 self._memory_metric.Stop(page, self._first_tab) |
| 44 self._memory_metric.AddResults(self._first_tab, results) | 45 self._memory_metric.AddResults(self._first_tab, results) |
| OLD | NEW |