| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 from metrics import memory | 5 from metrics import memory |
| 6 from metrics import power | 6 from metrics import power |
| 7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
| 8 | 8 |
| 9 class Memory(page_measurement.PageMeasurement): | 9 class Memory(page_measurement.PageMeasurement): |
| 10 def __init__(self): | 10 def __init__(self): |
| 11 super(Memory, self).__init__('RunStressMemory') | 11 super(Memory, self).__init__('RunStressMemory') |
| 12 self._memory_metric = None | 12 self._memory_metric = None |
| 13 self._power_metric = power.PowerMetric() | 13 self._power_metric = None |
| 14 |
| 15 def WillStartBrowser(self, browser): |
| 16 self._power_metric = power.PowerMetric(browser) |
| 14 | 17 |
| 15 def DidStartBrowser(self, browser): | 18 def DidStartBrowser(self, browser): |
| 16 self._memory_metric = memory.MemoryMetric(browser) | 19 self._memory_metric = memory.MemoryMetric(browser) |
| 17 | 20 |
| 18 def DidNavigateToPage(self, page, tab): | 21 def DidNavigateToPage(self, page, tab): |
| 19 self._memory_metric.Start(page, tab) | 22 self._memory_metric.Start(page, tab) |
| 20 self._power_metric.Start(page, tab) | 23 self._power_metric.Start(page, tab) |
| 21 | 24 |
| 22 def CustomizeBrowserOptions(self, options): | 25 def CustomizeBrowserOptions(self, options): |
| 23 memory.MemoryMetric.CustomizeBrowserOptions(options) | 26 memory.MemoryMetric.CustomizeBrowserOptions(options) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 35 # The tcmalloc_heap_profiler dumps files at regular | 38 # The tcmalloc_heap_profiler dumps files at regular |
| 36 # intervals (~20 secs). | 39 # intervals (~20 secs). |
| 37 # This is a minor optimization to ensure it'll dump the last file when | 40 # This is a minor optimization to ensure it'll dump the last file when |
| 38 # the test completes. | 41 # the test completes. |
| 39 tab.ExecuteJavaScript(""" | 42 tab.ExecuteJavaScript(""" |
| 40 if (chrome && chrome.memoryBenchmarking) { | 43 if (chrome && chrome.memoryBenchmarking) { |
| 41 chrome.memoryBenchmarking.heapProfilerDump('renderer', 'final'); | 44 chrome.memoryBenchmarking.heapProfilerDump('renderer', 'final'); |
| 42 chrome.memoryBenchmarking.heapProfilerDump('browser', 'final'); | 45 chrome.memoryBenchmarking.heapProfilerDump('browser', 'final'); |
| 43 } | 46 } |
| 44 """) | 47 """) |
| OLD | NEW |