| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import sys | 5 import sys |
| 6 | 6 |
| 7 from metrics import histogram_util | 7 from metrics import histogram_util |
| 8 from metrics import Metric | 8 from metrics import Metric |
| 9 | 9 |
| 10 _HISTOGRAMS = [ | 10 _HISTOGRAMS = [ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 def __init__(self, browser): | 29 def __init__(self, browser): |
| 30 super(MemoryMetric, self).__init__() | 30 super(MemoryMetric, self).__init__() |
| 31 self._browser = browser | 31 self._browser = browser |
| 32 self._start_commit_charge = self._browser.memory_stats['SystemCommitCharge'] | 32 self._start_commit_charge = self._browser.memory_stats['SystemCommitCharge'] |
| 33 self._memory_stats = None | 33 self._memory_stats = None |
| 34 self._histogram_start = dict() | 34 self._histogram_start = dict() |
| 35 self._histogram_delta = dict() | 35 self._histogram_delta = dict() |
| 36 | 36 |
| 37 @classmethod | 37 @classmethod |
| 38 def CustomizeBrowserOptions(cls, options): | 38 def CustomizeBrowserOptions(cls, options): |
| 39 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 39 options.AppendExtraBrowserArgs([ |
| 40 options.AppendExtraBrowserArg('--enable-memory-benchmarking') | 40 '--enable-stats-collection-bindings', |
| 41 # For a hard-coded set of Google pages (such as GMail), we produce custom | 41 '--enable-memory-benchmarking', |
| 42 # memory histograms (V8.Something_gmail) instead of the generic histograms | 42 # For a hard-coded set of Google pages (such as GMail), we produce |
| 43 # (V8.Something), if we detect that a renderer is only rendering this page | 43 # custom memory histograms (V8.Something_gmail) instead of the generic |
| 44 # and no other pages. For this test, we need to disable histogram | 44 # histograms (V8.Something), if we detect that a renderer is only |
| 45 # customizing, so that we get the same generic histograms produced for all | 45 # rendering this page and no other pages. For this test, we need to |
| 46 # pages. | 46 # disable histogram customizing, so that we get the same generic |
| 47 options.AppendExtraBrowserArg('--disable-histogram-customizer') | 47 # histograms produced for all pages. |
| 48 '--disable-histogram-customizer', |
| 48 | 49 |
| 49 # Old commandline flags used for reference builds. | 50 # Old commandline flags used for reference builds. |
| 50 options.AppendExtraBrowserArg('--dom-automation') | 51 '--dom-automation', |
| 51 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') | 52 '--reduce-security-for-dom-automation-tests', |
| 53 ]) |
| 52 | 54 |
| 53 def Start(self, page, tab): | 55 def Start(self, page, tab): |
| 54 """Start the per-page preparation for this metric. | 56 """Start the per-page preparation for this metric. |
| 55 | 57 |
| 56 Here, this consists of recording the start value of all the histograms. | 58 Here, this consists of recording the start value of all the histograms. |
| 57 """ | 59 """ |
| 58 for h in _HISTOGRAMS: | 60 for h in _HISTOGRAMS: |
| 59 histogram_data = histogram_util.GetHistogramFromDomAutomation( | 61 histogram_data = histogram_util.GetHistogramFromDomAutomation( |
| 60 h['type'], h['name'], tab) | 62 h['type'], h['name'], tab) |
| 61 # Histogram data may not be available | 63 # Histogram data may not be available |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 AddSummariesForProcessTypes(['Gpu'], 'gpu') | 138 AddSummariesForProcessTypes(['Gpu'], 'gpu') |
| 137 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') | 139 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') |
| 138 | 140 |
| 139 end_commit_charge = self._memory_stats['SystemCommitCharge'] | 141 end_commit_charge = self._memory_stats['SystemCommitCharge'] |
| 140 commit_charge_difference = end_commit_charge - self._start_commit_charge | 142 commit_charge_difference = end_commit_charge - self._start_commit_charge |
| 141 results.AddSummary('commit_charge', 'kb', commit_charge_difference, | 143 results.AddSummary('commit_charge', 'kb', commit_charge_difference, |
| 142 data_type='unimportant') | 144 data_type='unimportant') |
| 143 results.AddSummary('processes', 'count', self._memory_stats['ProcessCount'], | 145 results.AddSummary('processes', 'count', self._memory_stats['ProcessCount'], |
| 144 data_type='unimportant') | 146 data_type='unimportant') |
| 145 | 147 |
| OLD | NEW |