Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 telemetry import page_interaction | |
| 5 from telemetry import multi_page_benchmark | |
| 6 | |
| 7 MEMORY_HISTOGRAMS = [ | |
| 8 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, | |
| 9 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, | |
| 10 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] | |
| 11 | |
| 12 class MemoryBenchmark(multi_page_benchmark.MultiPageBenchmark): | |
| 13 def __init__(self): | |
| 14 super(MemoryBenchmark, self).__init__() | |
| 15 | |
| 16 @staticmethod | |
| 17 def GetMemoryHistograms(tab, results): | |
| 18 for histogram in MEMORY_HISTOGRAMS: | |
| 19 name = histogram['name'] | |
| 20 data = tab.runtime.Evaluate( | |
| 21 'window.domAutomationController.getHistogram("%s")' % name) | |
| 22 results.Add(name, histogram['units'], data, data_type='histogram') | |
| 23 | |
| 24 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
| |
| 25 for page in pages: | |
| 26 if hasattr(page, 'stress_memory'): | |
| 27 interaction = ( | |
| 28 page_interaction.FindClassWithName(page.stress_memory['action'])( | |
| 29 page.stress_memory)) | |
| 30 interaction.CustomizeBrowserOptions(options) | |
| 31 options.AppendExtraBrowserArg('--dom-automation') | |
| 32 | |
| 33 def MeasurePage(self, page, tab, results): | |
| 34 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
| |
| 35 interaction = ( | |
| 36 page_interaction.FindClassWithName(page.stress_memory['action'])( | |
| 37 page.stress_memory)) | |
| 38 tab.WaitForDocumentReadyStateToBeComplete() | |
| 39 interaction.PerformInteraction(page, tab) | |
| 40 self.GetMemoryHistograms(tab, results) | |
| OLD | NEW |