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 |
| index 27405734b3ba28f3a0526a2c1ab236139d32bf91..7f2715203516c979cb4bf2f90e4614e1bcc5e61b 100644 |
| --- a/tools/perf/perf_tools/memory_benchmark.py |
| +++ b/tools/perf/perf_tools/memory_benchmark.py |
| @@ -2,6 +2,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| from telemetry import multi_page_benchmark |
| +from telemetry import util |
| MEMORY_HISTOGRAMS = [ |
| {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, |
| @@ -15,6 +16,20 @@ BROWSER_MEMORY_HISTOGRAMS = [ |
| class MemoryBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| def __init__(self): |
| super(MemoryBenchmark, self).__init__('stress_memory') |
| + self._baselines = dict() |
| + |
| + def WillNavigateToPage(self, page, tab): |
|
nduca
2013/02/12 18:33:15
not sure i'd call this baselines. The word 'Baseli
marja
2013/02/13 16:09:30
Done.
|
| + for histogram in MEMORY_HISTOGRAMS: |
| + name = histogram['name'] |
|
nduca
2013/02/12 18:33:15
How about a histogram measurement object?
Histogr
marja
2013/02/13 16:09:30
Done.
|
| + data = self._GetHistogramFromDomAutomation(tab, 'getHistogram', name) |
| + if data: |
| + self._baselines[page.url + name] = data |
| + for histogram in BROWSER_MEMORY_HISTOGRAMS: |
| + name = histogram['name'] |
| + data = self._GetHistogramFromDomAutomation(tab, 'getBrowserHistogram', |
| + name) |
| + if data: |
| + self._baselines[page.url + name] = data |
| def CustomizeBrowserOptions(self, options): |
| options.AppendExtraBrowserArg('--dom-automation') |
| @@ -32,17 +47,26 @@ class MemoryBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| def MeasurePage(self, page, tab, results): |
| for histogram in MEMORY_HISTOGRAMS: |
| - self._GetHistogramFromDomAutomation(tab, 'getHistogram', histogram, |
| - results) |
| + name = histogram['name'] |
| + data = self._GetHistogramFromDomAutomation(tab, 'getHistogram', name) |
| + self._AddHistogramResult(histogram, page, data, results) |
| for histogram in BROWSER_MEMORY_HISTOGRAMS: |
| - self._GetHistogramFromDomAutomation(tab, 'getBrowserHistogram', histogram, |
| - results) |
| + name = histogram['name'] |
| + data = self._GetHistogramFromDomAutomation(tab, 'getBrowserHistogram', |
| + name) |
| + self._AddHistogramResult(histogram, page, data, results) |
| - def _GetHistogramFromDomAutomation(self, tab, func, histogram, results): |
| - name = histogram['name'] |
| + def _GetHistogramFromDomAutomation(self, tab, func, name): |
| js = ('window.domAutomationController.%s ? ' |
| 'window.domAutomationController.%s("%s") : ""' % (func, func, name)) |
| - data = tab.EvaluateJavaScript(js) |
| - if data: |
| - results.Add(name.replace('.', '_'), histogram['units'], data, |
| - data_type='histogram') |
| + return tab.EvaluateJavaScript(js) |
| + |
| + def _AddHistogramResult(self, histogram, page, data, results): |
| + if not data: |
| + return |
| + name = histogram['name'] |
| + if page.url + name not in self._baselines: |
| + return |
| + results.Add(name.replace('.', '_'), histogram['units'], |
| + util.SubtractHistogram(data, self._baselines[page.url + name]), |
| + data_type='histogram') |