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'}, |
(...skipping 11 matching lines...) Expand all Loading... |
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 | 26 |
27 def DidNavigateToPage(self, page, tab): | 27 def DidNavigateToPage(self, page, tab): |
28 for h in self.histograms: | 28 for h in self.histograms: |
29 h.Start(page, tab) | 29 h.Start(page, tab) |
30 | 30 |
31 def CustomizeBrowserOptions(self, options): | 31 def CustomizeBrowserOptions(self, options): |
32 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 32 options.AppendExtraBrowserArg('--dom-automation') |
33 # For a hard-coded set of Google pages (such as GMail), we produce custom | 33 # 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 | 34 # memory histograms (V8.Something_gmail) instead of the generic histograms |
35 # (V8.Something), if we detect that a renderer is only rendering this page | 35 # (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 | 36 # 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 | 37 # customizing, so that we get the same generic histograms produced for all |
38 # pages. | 38 # pages. |
39 options.AppendExtraBrowserArg('--disable-histogram-customizer') | 39 options.AppendExtraBrowserArg('--disable-histogram-customizer') |
40 options.AppendExtraBrowserArg('--memory-metrics') | 40 options.AppendExtraBrowserArg('--memory-metrics') |
41 options.AppendExtraBrowserArg( | 41 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') |
42 '--reduce-security-for-stats-collection-tests') | |
43 | 42 |
44 def CanRunForPage(self, page): | 43 def CanRunForPage(self, page): |
45 return hasattr(page, 'stress_memory') | 44 return hasattr(page, 'stress_memory') |
46 | 45 |
47 def MeasurePage(self, page, tab, results): | 46 def MeasurePage(self, page, tab, results): |
48 for h in self.histograms: | 47 for h in self.histograms: |
49 h.GetValue(page, tab, results) | 48 h.GetValue(page, tab, results) |
50 | 49 |
51 if tab.browser.is_profiler_active('tcmalloc-heap'): | 50 if tab.browser.is_profiler_active('tcmalloc-heap'): |
52 # The tcmalloc_heap_profiler dumps files at regular | 51 # The tcmalloc_heap_profiler dumps files at regular |
53 # intervals (~20 secs). | 52 # intervals (~20 secs). |
54 # This is a minor optimization to ensure it'll dump the last file when | 53 # This is a minor optimization to ensure it'll dump the last file when |
55 # the test completes. | 54 # the test completes. |
56 tab.ExecuteJavaScript(""" | 55 tab.ExecuteJavaScript(""" |
57 if (chrome && chrome.memoryBenchmarking) { | 56 if (chrome && chrome.memoryBenchmarking) { |
58 chrome.memoryBenchmarking.heapProfilerDump('final', 'renderer'); | 57 chrome.memoryBenchmarking.heapProfilerDump('final', 'renderer'); |
59 chrome.memoryBenchmarking.heapProfilerDump('final', 'browser'); | 58 chrome.memoryBenchmarking.heapProfilerDump('final', 'browser'); |
60 } | 59 } |
61 """) | 60 """) |
OLD | NEW |