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
3 # found in the LICENSE file.
4 from perf_tools
import histogram_measurement
5 from telemetry
.page
import page_benchmark
8 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'},
9 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'},
10 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'},
11 {'name': 'Memory.RendererUsed', 'units': 'kb'}]
13 BROWSER_MEMORY_HISTOGRAMS
= [
14 {'name': 'Memory.BrowserUsed', 'units': 'kb'}]
16 class MemoryBenchmark(page_benchmark
.PageBenchmark
):
18 super(MemoryBenchmark
, self
).__init
__('stress_memory')
20 [histogram_measurement
.HistogramMeasurement(
21 h
, histogram_measurement
.RENDERER_HISTOGRAM
)
22 for h
in MEMORY_HISTOGRAMS
] +
23 [histogram_measurement
.HistogramMeasurement(
24 h
, histogram_measurement
.BROWSER_HISTOGRAM
)
25 for h
in BROWSER_MEMORY_HISTOGRAMS
])
27 def DidNavigateToPage(self
, page
, tab
):
28 for h
in self
.histograms
:
31 def CustomizeBrowserOptions(self
, options
):
32 options
.AppendExtraBrowserArg('--dom-automation')
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
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
37 # customizing, so that we get the same generic histograms produced for all
39 options
.AppendExtraBrowserArg('--disable-histogram-customizer')
40 options
.AppendExtraBrowserArg('--memory-metrics')
41 options
.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests')
43 def CanRunForPage(self
, page
):
44 return hasattr(page
, 'stress_memory')
46 def MeasurePage(self
, page
, tab
, results
):
47 for h
in self
.histograms
:
48 h
.GetValue(page
, tab
, results
)