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

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

Issue 191383003: First cut of chrome-proxy (data reduction proxy) measurements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix rebasing. Created 6 years, 8 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 | « tools/perf/benchmarks/chrome_proxy.py ('k') | tools/perf/metrics/chrome_proxy.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import logging
5
6 from metrics import chrome_proxy
7 from metrics import loading
8 from telemetry.core import util
9 from telemetry.page import page_measurement
10
11
12 class ChromeProxyLatency(page_measurement.PageMeasurement):
13 """Chrome proxy latency measurement."""
14
15 def __init__(self, *args, **kwargs):
16 super(ChromeProxyLatency, self).__init__(*args, **kwargs)
17
18 def WillNavigateToPage(self, page, tab):
19 tab.ClearCache(force=True)
20
21 def MeasurePage(self, page, tab, results):
22 # Wait for the load event.
23 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
24 loading.LoadingMetric().AddResults(tab, results)
25
26
27 class ChromeProxyDataSaving(page_measurement.PageMeasurement):
28 """Chrome proxy data daving measurement."""
29 def __init__(self, *args, **kwargs):
30 super(ChromeProxyDataSaving, self).__init__(*args, **kwargs)
31 self._metrics = chrome_proxy.ChromeProxyMetric()
32
33 def WillNavigateToPage(self, page, tab):
34 tab.ClearCache(force=True)
35 self._metrics.Start(page, tab)
36
37 def MeasurePage(self, page, tab, results):
38 # Wait for the load event.
39 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
40 self._metrics.Stop(page, tab)
41 self._metrics.AddResultsForDataSaving(tab, results)
42
43
44 class ChromeProxyValidation(page_measurement.PageMeasurement):
45 """Base class for all chrome proxy correctness measurements."""
46
47 def __init__(self, restart_after_each_page=False):
48 super(ChromeProxyValidation, self).__init__(
49 needs_browser_restart_after_each_page=restart_after_each_page)
50 self._metrics = chrome_proxy.ChromeProxyMetric()
51 self._page = None
52 # Whether a timeout exception is expected during the test.
53 self._expect_timeout = False
54
55 def CustomizeBrowserOptions(self, options):
56 # Enable the chrome proxy (data reduction proxy).
57 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
58
59 def WillNavigateToPage(self, page, tab):
60 tab.ClearCache(force=True)
61 assert self._metrics
62 self._metrics.Start(page, tab)
63
64 def MeasurePage(self, page, tab, results):
65 self._page = page
66 # Wait for the load event.
67 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
68 assert self._metrics
69 self._metrics.Stop(page, tab)
70 self.AddResults(tab, results)
71
72 def AddResults(self, tab, results):
73 raise NotImplementedError
74
75 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
76 if hasattr(page, 'restart_after') and page.restart_after:
77 return True
78 return False
79
80 def RunNavigateSteps(self, page, tab):
81 # The redirect from safebrowsing causes a timeout. Ignore that.
82 try:
83 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab)
84 except util.TimeoutException, e:
85 if self._expect_timeout:
86 logging.warning('Navigation timeout on page %s',
87 page.name if page.name else page.url)
88 else:
89 raise e
90
91
92 class ChromeProxyHeaders(ChromeProxyValidation):
93 """Correctness measurement for response headers."""
94
95 def __init__(self):
96 super(ChromeProxyHeaders, self).__init__()
97
98 def AddResults(self, tab, results):
99 self._metrics.AddResultsForHeaderValidation(tab, results)
100
101
102 class ChromeProxyBypass(ChromeProxyValidation):
103 """Correctness measurement for bypass responses."""
104
105 def __init__(self):
106 super(ChromeProxyBypass, self).__init__(restart_after_each_page=True)
107
108 def AddResults(self, tab, results):
109 self._metrics.AddResultsForBypass(tab, results)
110
111
112 class ChromeProxySafebrowsing(ChromeProxyValidation):
113 """Correctness measurement for safebrowsing."""
114
115 def __init__(self):
116 super(ChromeProxySafebrowsing, self).__init__()
117
118 def WillNavigateToPage(self, page, tab):
119 super(ChromeProxySafebrowsing, self).WillNavigateToPage(page, tab)
120 self._expect_timeout = True
121
122 def AddResults(self, tab, results):
123 self._metrics.AddResultsForSafebrowsing(tab, results)
124
125
126 class ChromeProxySmoke(ChromeProxyValidation):
127 """Smoke measurement for basic chrome proxy correctness."""
128
129 def __init__(self):
130 super(ChromeProxySmoke, self).__init__()
131
132 def WillNavigateToPage(self, page, tab):
133 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab)
134 if page.name == 'safebrowsing':
135 self._expect_timeout = True
136
137 def AddResults(self, tab, results):
138 # Map a page name to its AddResults func.
139 page_to_metrics = {
140 'header validation': [self._metrics.AddResultsForHeaderValidation],
141 'compression: image': [
142 self._metrics.AddResultsForHeaderValidation,
143 self._metrics.AddResultsForDataSaving,
144 ],
145 'compression: javascript': [
146 self._metrics.AddResultsForHeaderValidation,
147 self._metrics.AddResultsForDataSaving,
148 ],
149 'compression: css': [
150 self._metrics.AddResultsForHeaderValidation,
151 self._metrics.AddResultsForDataSaving,
152 ],
153 'bypass': [self._metrics.AddResultsForBypass],
154 'safebrowsing': [self._metrics.AddResultsForSafebrowsing],
155 }
156 if not self._page.name in page_to_metrics:
157 raise page_measurement.MeasurementFailure(
158 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % (
159 self._page.name, page_to_metrics.keys()))
160 for add_result in page_to_metrics[self._page.name]:
161 add_result(tab, results)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/chrome_proxy.py ('k') | tools/perf/metrics/chrome_proxy.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698