OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 import sys | 4 import sys |
5 | 5 |
6 from perf_tools import histogram_measurement | 6 from perf_tools import histogram_measurement |
7 from telemetry.core import util | 7 from telemetry.core import util |
8 from telemetry.page import page_benchmark | 8 from telemetry.page import page_benchmark |
9 | 9 |
10 MEMORY_HISTOGRAMS = [ | 10 MEMORY_HISTOGRAMS = [ |
11 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, | 11 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, |
12 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, | 12 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, |
13 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] | 13 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] |
14 | 14 |
15 class PageCycler(page_benchmark.PageBenchmark): | 15 class PageCycler(page_benchmark.PageBenchmark): |
16 def WillNavigateToPage(self, page, tab): | 16 def WillNavigateToPage(self, page, tab): |
17 # pylint: disable=W0201 | 17 # pylint: disable=W0201 |
18 self.histograms = [histogram_measurement.HistogramMeasurement( | 18 self.histograms = [histogram_measurement.HistogramMeasurement( |
19 h, histogram_measurement.RENDERER_HISTOGRAM) | 19 h, histogram_measurement.RENDERER_HISTOGRAM) |
20 for h in MEMORY_HISTOGRAMS] | 20 for h in MEMORY_HISTOGRAMS] |
21 for h in self.histograms: | 21 for h in self.histograms: |
22 h.Start(page, tab) | 22 h.Start(page, tab) |
23 # pylint: disable=W0201 | 23 # pylint: disable=W0201 |
24 self.start_commit_charge = tab.browser.memory_stats['SystemCommitCharge'] | 24 self.start_commit_charge = tab.browser.memory_stats['SystemCommitCharge'] |
25 | 25 |
26 def CustomizeBrowserOptions(self, options): | 26 def CustomizeBrowserOptions(self, options): |
27 options.AppendExtraBrowserArg('--dom-automation') | 27 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') |
28 options.AppendExtraBrowserArg('--js-flags=--expose_gc') | 28 options.AppendExtraBrowserArg('--js-flags=--expose_gc') |
29 options.AppendExtraBrowserArg('--no-sandbox') | 29 options.AppendExtraBrowserArg('--no-sandbox') |
30 | 30 |
31 def MeasureMemory(self, tab, results): | 31 def MeasureMemory(self, tab, results): |
32 memory = tab.browser.memory_stats | 32 memory = tab.browser.memory_stats |
33 if not memory['Browser']: | 33 if not memory['Browser']: |
34 return | 34 return |
35 | 35 |
36 metric = 'rss' | 36 metric = 'rss' |
37 if sys.platform == 'win32': | 37 if sys.platform == 'win32': |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 self.MeasureIO(tab, results) | 149 self.MeasureIO(tab, results) |
150 | 150 |
151 for h in self.histograms: | 151 for h in self.histograms: |
152 h.GetValue(page, tab, results) | 152 h.GetValue(page, tab, results) |
153 | 153 |
154 def _IsNavigatedToReport(): | 154 def _IsNavigatedToReport(): |
155 return tab.GetCookieByName('__navigated_to_report') == '1' | 155 return tab.GetCookieByName('__navigated_to_report') == '1' |
156 util.WaitFor(_IsNavigatedToReport, 60, poll_interval=5) | 156 util.WaitFor(_IsNavigatedToReport, 60, poll_interval=5) |
157 timings = tab.EvaluateJavaScript('__get_timings()').split(',') | 157 timings = tab.EvaluateJavaScript('__get_timings()').split(',') |
158 results.Add('t', 'ms', [int(t) for t in timings], chart_name='times') | 158 results.Add('t', 'ms', [int(t) for t in timings], chart_name='times') |
OLD | NEW |