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

Unified 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: . Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/measurements/chrome_proxy.py
diff --git a/tools/perf/measurements/chrome_proxy.py b/tools/perf/measurements/chrome_proxy.py
new file mode 100644
index 0000000000000000000000000000000000000000..d7a389445cf30f3d70240c873e82cf2caaaa21fa
--- /dev/null
+++ b/tools/perf/measurements/chrome_proxy.py
@@ -0,0 +1,160 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import logging
+
+from metrics import chrome_proxy
+from telemetry.core import util
+from telemetry.page import page_measurement
+
+
bengr 2014/03/12 18:17:36 I'm a little confused about the file naming. What'
bolian 2014/03/19 00:20:03 I am trying to fit into the Telemetry test structu
+class ChromeProxyLatency(page_measurement.PageMeasurement):
tonyg 2014/03/12 02:08:37 Rather than creating a new measurement, I recommen
bolian 2014/03/19 00:20:03 PageCycler measurement does not call LoadingMetric
+ """Chrome proxy latency measurement."""
+
+ def __init__(self, *args, **kwargs):
+ super(ChromeProxyLatency, self).__init__(*args, **kwargs)
+
+ def WillNavigateToPage(self, page, tab):
+ tab.ClearCache(force=True)
+
+ def MeasurePage(self, page, tab, results):
+ # Wait for the load event.
+ tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
+ chrome_proxy.ChromeProxyLatency().AddResults(tab, results)
+
+
+class ChromeProxyDataSaving(page_measurement.PageMeasurement):
+ """Chrome proxy data daving measurement."""
+ def __init__(self, *args, **kwargs):
+ super(ChromeProxyDataSaving, self).__init__(*args, **kwargs)
+ self._metrics = chrome_proxy.ChromeProxyTimelineMetrics()
+
+ def WillNavigateToPage(self, page, tab):
+ tab.ClearCache(force=True)
+ self._metrics.Start(page, tab)
+
+ def MeasurePage(self, page, tab, results):
+ # Wait for the load event.
+ tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
+ self._metrics.Stop(page, tab)
+ self._metrics.AddResultsForDataSaving(tab, results)
+
+
+class ChromeProxyValidation(page_measurement.PageMeasurement):
+ """Base class for all chrome proxy correctness measurement."""
bengr 2014/03/12 18:17:36 nit: "measurements". Also, why "measurement" and n
bolian 2014/03/19 00:20:03 Done. A measurement is a page set in Telemetry ter
+
+ def __init__(self, restart_after_each_run=False):
+ super(ChromeProxyValidation, self).__init__(
+ needs_browser_restart_after_each_run=restart_after_each_run)
+ self._metrics = chrome_proxy.ChromeProxyTimelineMetrics()
+ self._page = None
+ # Whether a timeout exception is expected during the test.
+ self._expect_timeout = False
+
+ def CustomizeBrowserOptions(self, options):
+ # Enable the chrome proxy (data reduction proxy).
+ options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
+
+ def WillNavigateToPage(self, page, tab):
+ tab.ClearCache(force=True)
+ assert self._metrics
+ self._metrics.Start(page, tab)
+
+ def MeasurePage(self, page, tab, results):
+ self._page = page
+ # Wait for the load event.
+ tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
+ assert self._metrics
+ self._metrics.Stop(page, tab)
+ self.AddResults(tab, results)
+
+ def AddResults(self, tab, results):
+ raise NotImplementedError
+
+ def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
+ if hasattr(page, 'restart_after') and page.restart_after:
+ return True
+ return False
+
+ def RunNavigateSteps(self, page, tab):
+ # The redirect from safebrowsing causes a timeout. Ignore that.
+ try:
+ super(ChromeProxyValidation, self).RunNavigateSteps(page, tab)
+ except util.TimeoutException, e:
+ if self._expect_timeout:
+ logging.warning('Navigation timeout on page %s',
+ page.name if page.name else page.url)
+ else:
+ raise e
+
+
+class ChromeProxyHeaders(ChromeProxyValidation):
+ """Correctness measurement for response headers."""
+
+ def __init__(self):
+ super(ChromeProxyHeaders, self).__init__()
+
+ def AddResults(self, tab, results):
+ self._metrics.AddResultsForHeaderValidation(tab, results)
+
+
+class ChromeProxyBypass(ChromeProxyValidation):
+ """Correctness measurement for bypass responses."""
+
+ def __init__(self):
+ super(ChromeProxyBypass, self).__init__(restart_after_each_run=True)
+
+ def AddResults(self, tab, results):
+ self._metrics.AddResultsForBypass(tab, results)
+
+
+class ChromeProxySafebrowsing(ChromeProxyValidation):
+ """Correctness measurement for safebrowsing."""
+
+ def __init__(self):
+ super(ChromeProxySafebrowsing, self).__init__()
+
+ def WillNavigateToPage(self, page, tab):
+ super(ChromeProxySafebrowsing, self).WillNavigateToPage(page, tab)
+ self._expect_timeout = True
+
+ def AddResults(self, tab, results):
+ self._metrics.AddResultsForSafebrowsing(tab, results)
+
+
+class ChromeProxySmoke(ChromeProxyValidation):
+ """Smoke measurement for basic chrome proxy correctness."""
+
+ def __init__(self):
+ super(ChromeProxySmoke, self).__init__()
+
+ def WillNavigateToPage(self, page, tab):
+ super(ChromeProxySmoke, self).WillNavigateToPage(page, tab)
+ if page.name == 'safebrowsing':
+ self._expect_timeout = True
+
+ def AddResults(self, tab, results):
+ # Map a page name to its AddResults func.
+ page_to_metrics = {
+ 'header validation': [self._metrics.AddResultsForHeaderValidation],
+ 'compression: image': [
+ self._metrics.AddResultsForHeaderValidation,
+ self._metrics.AddResultsForDataSaving,
+ ],
+ 'compression: javascript': [
+ self._metrics.AddResultsForHeaderValidation,
+ self._metrics.AddResultsForDataSaving,
+ ],
+ 'compression: css': [
+ self._metrics.AddResultsForHeaderValidation,
+ self._metrics.AddResultsForDataSaving,
+ ],
+ 'bypass': [self._metrics.AddResultsForBypass],
+ 'safebrowsing': [self._metrics.AddResultsForSafebrowsing],
+ }
+ if not self._page.name in page_to_metrics:
+ raise page_measurement.MeasurementFailure(
+ 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % (
+ self._page.name, page_to_metrics.keys()))
+ for add_result in page_to_metrics[self._page.name]:
+ add_result(tab, results)

Powered by Google App Engine
This is Rietveld 408576698