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..b2704478d6a1f1cd9d97eff68cda3604b31e744d |
| --- /dev/null |
| +++ b/tools/perf/perf_tools/memory_benchmark.py |
| @@ -0,0 +1,49 @@ |
| +# 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. |
| +import copy |
| + |
| +from chrome_remote_control import interaction |
| +from chrome_remote_control import multi_page_benchmark |
| +from chrome_remote_control import test_helper_interaction #pylint: disable=W0611 |
| + |
| +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__() |
| + self._interactions = [] |
| + self._results = {} |
| + |
| + @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, 'histogram') |
|
tonyg
2012/11/02 18:57:34
Since the 4th parameter is optional, please name i
marja
2012/11/05 14:43:25
Done.
|
| + |
| + def CustomizeBrowserOptions(self, options): |
| + options.extra_browser_args.append('--dom-automation') |
| + |
| + def DoNextInteraction(self, page, tab): |
| + if not self._interactions: |
| + return False |
| + data = self._interactions[0] |
| + self._interactions = self._interactions[1:] |
| + i = interaction.FindClassWithName(data['type'])(data) |
| + i.PerformInteraction(page, tab, self) |
| + return True |
| + |
| + def DidPerformInteraction(self, _, page, tab): |
| + if not self.DoNextInteraction(page, tab): |
| + self.GetMemoryHistograms(tab, self._results) |
| + |
| + def MeasurePage(self, page, tab, results): |
| + self._interactions = copy.copy(page.interactions) |
| + self._results = results |
| + tab.WaitForDocumentReadyStateToBeComplete() |
| + self.DoNextInteraction(page, tab) |