Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: tools/perf/perf_tools/memory_measurement.py

Issue 15093008: Telemetry: integrates memory_measurement with TCMalloc dumps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TCMallocHeapProfiler Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:
Dai Mikurube (NOT FULLTIME) 2013/05/14 17:02:10 Ah, I thought that this condition can coexist with
53 dumps = eval(tab.EvaluateJavaScript("""
tonyg 2013/05/14 18:54:13 Please use json instead of eval
bulach 2013/05/15 10:22:56 Done.
54 JSON.stringify([
55 chrome.memoryBenchmarking.heapProfilerDump('renderer'),
56 chrome.memoryBenchmarking.heapProfilerDump('browser'),
57 ]);
58 """))
59 if dumps:
60 print 'TCMalloc heap dumps available at ', dumps
tonyg 2013/05/14 16:52:44 I don't like this code in the MemoryMeasurement be
bulach 2013/05/14 17:54:47 "it's complicated" :) - Profiler knows nothing abo
tonyg 2013/05/14 18:54:13 How long is the interval? If it is sufficiently sh
bulach 2013/05/15 10:22:56 the interval is relatively large right now. it tak
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698