Chromium Code Reviews| Index: tools/perf/perf_tools/memory_benchmark.py |
| diff --git a/tools/perf/perf_tools/memory_benchmark.py b/tools/perf/perf_tools/memory_benchmark.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4bd6eb77ff338ba01800d82b1ac9cf0816eb6280 |
| --- /dev/null |
| +++ b/tools/perf/perf_tools/memory_benchmark.py |
| @@ -0,0 +1,40 @@ |
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| +from telemetry import page_interaction |
| +from telemetry import multi_page_benchmark |
| + |
| +MEMORY_HISTOGRAMS = [ |
| + {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, |
| + {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, |
| + {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] |
| + |
| +class MemoryBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| + def __init__(self): |
| + super(MemoryBenchmark, self).__init__() |
| + |
| + @staticmethod |
| + def GetMemoryHistograms(tab, results): |
| + for histogram in MEMORY_HISTOGRAMS: |
| + name = histogram['name'] |
| + data = tab.runtime.Evaluate( |
| + 'window.domAutomationController.getHistogram("%s")' % name) |
| + results.Add(name, histogram['units'], data, data_type='histogram') |
| + |
| + def CustomizeBrowserOptions(self, pages, options): |
|
nduca
2012/11/09 19:39:06
I'd rather you not make this change. If you do the
marja
2012/11/12 12:23:31
Ok, I moved the interactions to MultiPageBenchmark
|
| + for page in pages: |
| + if hasattr(page, 'stress_memory'): |
| + interaction = ( |
| + page_interaction.FindClassWithName(page.stress_memory['action'])( |
| + page.stress_memory)) |
| + interaction.CustomizeBrowserOptions(options) |
| + options.AppendExtraBrowserArg('--dom-automation') |
| + |
| + def MeasurePage(self, page, tab, results): |
| + if hasattr(page, 'stress_memory'): |
|
nduca
2012/11/09 19:39:06
This stuff is why you want the page_runner to unde
marja
2012/11/12 12:23:31
K, I added CanRunForPage to PageTest, and the Page
|
| + interaction = ( |
| + page_interaction.FindClassWithName(page.stress_memory['action'])( |
| + page.stress_memory)) |
| + tab.WaitForDocumentReadyStateToBeComplete() |
| + interaction.PerformInteraction(page, tab) |
| + self.GetMemoryHistograms(tab, results) |