Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: tools/perf/measurements/page_cycler.py

Issue 22539003: [Telemetry] Report network metrics for the page cycler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/perf/metrics/network.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4
5 """The page cycler measurement. 5 """The page cycler measurement.
6 6
7 This measurement registers a window load handler in which is forces a layout and 7 This measurement registers a window load handler in which is forces a layout and
8 then records the value of performance.now(). This call to now() measures the 8 then records the value of performance.now(). This call to now() measures the
9 time from navigationStart (immediately after the previous page's beforeunload 9 time from navigationStart (immediately after the previous page's beforeunload
10 event) until after the layout in the page's load event. In addition, two garbage 10 event) until after the layout in the page's load event. In addition, two garbage
11 collections are performed in between the page loads (in the beforeunload event). 11 collections are performed in between the page loads (in the beforeunload event).
12 This extra garbage collection time is not included in the measurement times. 12 This extra garbage collection time is not included in the measurement times.
13 13
14 Finally, various memory and IO statistics are gathered at the very end of 14 Finally, various memory and IO statistics are gathered at the very end of
15 cycling all pages. 15 cycling all pages.
16 """ 16 """
17 17
18 import os 18 import os
19 import sys 19 import sys
20 20
21 from metrics import histogram 21 from metrics import histogram
22 from metrics import memory 22 from metrics import memory
23 from metrics import network
23 from telemetry.core import util 24 from telemetry.core import util
24 from telemetry.page import page_measurement 25 from telemetry.page import page_measurement
25 26
26 27
27 MEMORY_HISTOGRAMS = [ 28 MEMORY_HISTOGRAMS = [
28 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, 29 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'},
29 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, 30 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'},
30 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] 31 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}]
31 32
32 33
33 class PageCycler(page_measurement.PageMeasurement): 34 class PageCycler(page_measurement.PageMeasurement):
34 def __init__(self, *args, **kwargs): 35 def __init__(self, *args, **kwargs):
35 super(PageCycler, self).__init__(*args, **kwargs) 36 super(PageCycler, self).__init__(*args, **kwargs)
36 37
37 with open(os.path.join(os.path.dirname(__file__), 38 with open(os.path.join(os.path.dirname(__file__),
38 'page_cycler.js'), 'r') as f: 39 'page_cycler.js'), 'r') as f:
39 self._page_cycler_js = f.read() 40 self._page_cycler_js = f.read()
40 41
41 self._memory_metric = None 42 self._memory_metric = None
42 self._histograms = None 43 self._histograms = None
44 self._network_metric = network.NetworkMetric()
43 45
44 def AddCommandLineOptions(self, parser): 46 def AddCommandLineOptions(self, parser):
45 # The page cyclers should default to 10 iterations. In order to change the 47 # The page cyclers should default to 10 iterations. In order to change the
46 # default of an option, we must remove and re-add it. 48 # default of an option, we must remove and re-add it.
47 # TODO: Remove this after transition to run_benchmark. 49 # TODO: Remove this after transition to run_benchmark.
48 pageset_repeat_option = parser.get_option('--pageset-repeat') 50 pageset_repeat_option = parser.get_option('--pageset-repeat')
49 pageset_repeat_option.default = 10 51 pageset_repeat_option.default = 10
50 parser.remove_option('--pageset-repeat') 52 parser.remove_option('--pageset-repeat')
51 parser.add_option(pageset_repeat_option) 53 parser.add_option(pageset_repeat_option)
52 54
53 def DidStartBrowser(self, browser): 55 def DidStartBrowser(self, browser):
54 """Initialize metrics once right after the browser has been launched.""" 56 """Initialize metrics once right after the browser has been launched."""
55 self._memory_metric = memory.MemoryMetric(browser) 57 self._memory_metric = memory.MemoryMetric(browser)
56 self._memory_metric.Start() 58 self._memory_metric.Start()
57 self._histograms = [histogram.HistogramMetric( 59 self._histograms = [histogram.HistogramMetric(
58 h, histogram.RENDERER_HISTOGRAM) 60 h, histogram.RENDERER_HISTOGRAM)
59 for h in MEMORY_HISTOGRAMS] 61 for h in MEMORY_HISTOGRAMS]
60 62
61 def DidStartHTTPServer(self, tab): 63 def DidStartHTTPServer(self, tab):
62 # Avoid paying for a cross-renderer navigation on the first page on legacy 64 # Avoid paying for a cross-renderer navigation on the first page on legacy
63 # page cyclers which use the filesystem. 65 # page cyclers which use the filesystem.
64 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) 66 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html'))
65 67
66 def WillNavigateToPage(self, page, tab): 68 def WillNavigateToPage(self, page, tab):
67 page.script_to_evaluate_on_commit = self._page_cycler_js 69 page.script_to_evaluate_on_commit = self._page_cycler_js
70 self._network_metric.Start(page, tab)
68 71
69 def DidNavigateToPage(self, page, tab): 72 def DidNavigateToPage(self, page, tab):
70 for h in self._histograms: 73 for h in self._histograms:
71 h.Start(page, tab) 74 h.Start(page, tab)
72 75
73 def CustomizeBrowserOptions(self, options): 76 def CustomizeBrowserOptions(self, options):
74 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') 77 options.AppendExtraBrowserArg('--enable-stats-collection-bindings')
75 options.AppendExtraBrowserArg('--js-flags=--expose_gc') 78 options.AppendExtraBrowserArg('--js-flags=--expose_gc')
76 options.AppendExtraBrowserArg('--no-sandbox') 79 options.AppendExtraBrowserArg('--no-sandbox')
77 80
78 # Old commandline flags used for reference builds. 81 # Old commandline flags used for reference builds.
79 options.AppendExtraBrowserArg('--dom-automation') 82 options.AppendExtraBrowserArg('--dom-automation')
80 83
84 # TODO(tonyg): NetworkMetric should be responsible for setting these.
85 # http://crbug.com/271177
86 options.AppendExtraBrowserArg('--enable-benchmarking')
87 options.AppendExtraBrowserArg('--enable-stats-table')
88
81 # Temporarily disable typical_25 page set on mac. 89 # Temporarily disable typical_25 page set on mac.
82 if sys.platform == 'darwin' and sys.argv[-1].endswith('/typical_25.json'): 90 if sys.platform == 'darwin' and sys.argv[-1].endswith('/typical_25.json'):
83 print 'typical_25 is currently disabled on mac. Skipping test.' 91 print 'typical_25 is currently disabled on mac. Skipping test.'
84 sys.exit(0) 92 sys.exit(0)
85 93
86 def MeasureIO(self, tab, results): 94 def MeasureIO(self, tab, results):
87 io_stats = tab.browser.io_stats 95 io_stats = tab.browser.io_stats
88 if not io_stats['Browser']: 96 if not io_stats['Browser']:
89 return 97 return
90 98
(...skipping 23 matching lines...) Expand all
114 AddSummariesForProcessType('Gpu', 'gpu') 122 AddSummariesForProcessType('Gpu', 'gpu')
115 123
116 def MeasurePage(self, page, tab, results): 124 def MeasurePage(self, page, tab, results):
117 def _IsDone(): 125 def _IsDone():
118 return bool(tab.EvaluateJavaScript('__pc_load_time')) 126 return bool(tab.EvaluateJavaScript('__pc_load_time'))
119 util.WaitFor(_IsDone, 60) 127 util.WaitFor(_IsDone, 60)
120 128
121 for h in self._histograms: 129 for h in self._histograms:
122 h.GetValue(page, tab, results) 130 h.GetValue(page, tab, results)
123 131
132 self._network_metric.Stop(page, tab)
133 self._network_metric.AddResults(tab, results)
134
124 results.Add('page_load_time', 'ms', 135 results.Add('page_load_time', 'ms',
125 int(float(tab.EvaluateJavaScript('__pc_load_time'))), 136 int(float(tab.EvaluateJavaScript('__pc_load_time'))),
126 chart_name='times') 137 chart_name='times')
127 138
128 def DidRunTest(self, tab, results): 139 def DidRunTest(self, tab, results):
129 self._memory_metric.Stop() 140 self._memory_metric.Stop()
130 self._memory_metric.AddResults(tab, results) 141 self._memory_metric.AddResults(tab, results)
131 self.MeasureIO(tab, results) 142 self.MeasureIO(tab, results)
132 143
OLDNEW
« no previous file with comments | « no previous file | tools/perf/metrics/network.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698