OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 from perf_tools import histogram_metric | 4 from perf_tools import histogram_metric |
5 from telemetry.page import page_measurement | 5 from telemetry.page import page_measurement |
6 | 6 |
7 MEMORY_HISTOGRAMS = [ | 7 MEMORY_HISTOGRAMS = [ |
8 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, | 8 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, |
9 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, | 9 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, |
10 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}, | 10 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}, |
11 {'name': 'Memory.RendererUsed', 'units': 'kb'}] | 11 {'name': 'Memory.RendererUsed', 'units': 'kb'}] |
12 | 12 |
13 BROWSER_MEMORY_HISTOGRAMS = [ | 13 BROWSER_MEMORY_HISTOGRAMS = [ |
14 {'name': 'Memory.BrowserUsed', 'units': 'kb'}] | 14 {'name': 'Memory.BrowserUsed', 'units': 'kb'}] |
15 | 15 |
16 class MemoryMeasurement(page_measurement.PageMeasurement): | 16 class MemoryMeasurement(page_measurement.PageMeasurement): |
17 def __init__(self): | 17 def __init__(self): |
18 super(MemoryMeasurement, self).__init__('stress_memory') | 18 super(MemoryMeasurement, self).__init__('stress_memory') |
19 self.histograms = ( | 19 self.histograms = ( |
20 [histogram_metric.HistogramMetric( | 20 [histogram_metric.HistogramMetric( |
21 h, histogram_metric.RENDERER_HISTOGRAM) | 21 h, histogram_metric.RENDERER_HISTOGRAM) |
22 for h in MEMORY_HISTOGRAMS] + | 22 for h in MEMORY_HISTOGRAMS] + |
23 [histogram_metric.HistogramMetric( | 23 [histogram_metric.HistogramMetric( |
24 h, histogram_metric.BROWSER_HISTOGRAM) | 24 h, histogram_metric.BROWSER_HISTOGRAM) |
25 for h in BROWSER_MEMORY_HISTOGRAMS]) | 25 for h in BROWSER_MEMORY_HISTOGRAMS]) |
26 self._is_running_tcmalloc_heap_profiler = False | |
26 | 27 |
27 def DidNavigateToPage(self, page, tab): | 28 def DidNavigateToPage(self, page, tab): |
28 for h in self.histograms: | 29 for h in self.histograms: |
29 h.Start(page, tab) | 30 h.Start(page, tab) |
30 | 31 |
31 def CustomizeBrowserOptions(self, options): | 32 def CustomizeBrowserOptions(self, options): |
32 options.AppendExtraBrowserArg('--dom-automation') | 33 options.AppendExtraBrowserArg('--dom-automation') |
33 # For a hard-coded set of Google pages (such as GMail), we produce custom | 34 # For a hard-coded set of Google pages (such as GMail), we produce custom |
34 # memory histograms (V8.Something_gmail) instead of the generic histograms | 35 # memory histograms (V8.Something_gmail) instead of the generic histograms |
35 # (V8.Something), if we detect that a renderer is only rendering this page | 36 # (V8.Something), if we detect that a renderer is only rendering this page |
36 # and no other pages. For this test, we need to disable histogram | 37 # and no other pages. For this test, we need to disable histogram |
37 # customizing, so that we get the same generic histograms produced for all | 38 # customizing, so that we get the same generic histograms produced for all |
38 # pages. | 39 # pages. |
39 options.AppendExtraBrowserArg('--disable-histogram-customizer') | 40 options.AppendExtraBrowserArg('--disable-histogram-customizer') |
40 options.AppendExtraBrowserArg('--memory-metrics') | 41 options.AppendExtraBrowserArg('--memory-metrics') |
41 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') | 42 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') |
43 self._is_running_tcmalloc_heap_profiler = (options.profiler_tool == | |
44 'tcmalloc-heap') | |
42 | 45 |
43 def CanRunForPage(self, page): | 46 def CanRunForPage(self, page): |
44 return hasattr(page, 'stress_memory') | 47 return hasattr(page, 'stress_memory') |
45 | 48 |
46 def MeasurePage(self, page, tab, results): | 49 def MeasurePage(self, page, tab, results): |
47 for h in self.histograms: | 50 for h in self.histograms: |
48 h.GetValue(page, tab, results) | 51 h.GetValue(page, tab, results) |
52 if self._is_running_tcmalloc_heap_profiler: | |
tonyg
2013/05/15 15:46:17
I think you could remove the member variable and c
bulach
2013/05/16 09:01:30
that's actually a good point.
browser doesn't expo
| |
53 # The tcmalloc_heap_profiler dumps files at regular | |
54 # intervals (~20 secs). | |
55 # This is a minor optimization to ensure it'll dump the last file when | |
56 # the test completes. | |
57 tab.ExecuteJavaScript(""" | |
58 if (chrome && chrome.memoryBenchmarking) { | |
59 chrome.memoryBenchmarking.heapProfilerDump('final', 'renderer'); | |
60 chrome.memoryBenchmarking.heapProfilerDump('final', 'browser'); | |
61 } | |
62 """) | |
OLD | NEW |