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

Unified Diff: telemetry/telemetry/page/cache_temperature.py

Issue 3011263002: Add cache_temperature state "HOT" (Closed)
Patch Set: use methods for serviceworker in tab Created 3 years, 3 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: telemetry/telemetry/page/cache_temperature.py
diff --git a/telemetry/telemetry/page/cache_temperature.py b/telemetry/telemetry/page/cache_temperature.py
index 3e22d02eac6e41389f4778bb07582113bbae4631..92887442a6816935e4914921cd7b3c1ea7604ef4 100644
--- a/telemetry/telemetry/page/cache_temperature.py
+++ b/telemetry/telemetry/page/cache_temperature.py
@@ -12,17 +12,17 @@ https://docs.google.com/document/u/1/d/12D7tkhZi887g9d0U2askU9JypU_wYiEI7Lw0bfwx
import logging
-import py_utils
-
# Default Cache Temperature. The page doesn't care which browser cache state
# it is run on.
ANY = 'any'
# Emulates cold runs. Clears various caches and data with using tab.ClearCache()
# and tab.ClearDataForOrigin().
COLD = 'cold'
-# Emulates warm runs. Ensures that the page was visited at least once just
-# before the run.
+# Emulates warm runs. Ensures that the page was visited once before the run.
WARM = 'warm'
+# Emulates hot runs. Ensures that the page was visited at least twice before
+# the run.
+HOT = 'hot'
# These regacy states will be removed after chromium test scripts are adapted
# to new states.
@@ -46,7 +46,6 @@ class MarkTelemetryInternal(object):
def __exit__(self, exception_type, exception_value, traceback):
if exception_type:
return True
-
marker = 'telemetry.internal.%s.end' % self.identifier
self.browser.tabs[0].ExecuteJavaScript(
"console.time({{ marker }});", marker=marker)
@@ -54,16 +53,16 @@ class MarkTelemetryInternal(object):
"console.timeEnd({{ marker }});", marker=marker)
return True
-def ClearCache(browser):
+def ClearCacheAndData(browser, url):
tab = browser.tabs[0]
tab.ClearCache(force=True)
+ tab.ClearDataForOrigin(url)
def WarmCache(page, browser):
with MarkTelemetryInternal(browser, 'warm_cache'):
tab = browser.tabs[0]
- tab.Navigate(page.url)
- py_utils.WaitFor(tab.HasReachedQuiescence, 60)
- tab.WaitForDocumentReadyStateToBeComplete()
+ page.RunNavigateSteps(tab.action_runner)
+ page.RunPageInteractions(tab.action_runner)
tab.Navigate("about:blank")
tab.WaitForDocumentReadyStateToBeComplete()
@@ -84,12 +83,11 @@ def EnsurePageCacheTemperature(page, browser, previous_page=None):
tab = browser.tabs[0]
tab.Navigate("http://does.not.exist")
tab.WaitForDocumentReadyStateToBeComplete()
- ClearCache(browser)
+ ClearCacheAndData(browser, page.url)
elif temperature == WARM:
if (previous_page is not None and
previous_page.url == page.url and
- (previous_page.cache_temperature == COLD or
- previous_page.cache_temperature == WARM)):
+ previous_page.cache_temperature == COLD):
if '#' in page.url:
# Navigate to inexistent URL to avoid in-page hash navigation.
# Note: Unlike PCv1, PCv2 iterates the same URL for different cache
@@ -99,5 +97,29 @@ def EnsurePageCacheTemperature(page, browser, previous_page=None):
tab = browser.tabs[0]
tab.Navigate("http://does.not.exist")
tab.WaitForDocumentReadyStateToBeComplete()
- return
- WarmCache(page, browser)
+ else:
+ ClearCacheAndData(browser, page.url)
+ WarmCache(page, browser)
shimazu 2017/09/25 02:30:35 I'm wondering if it's correct though I'm not famil
shimazu 2017/09/25 05:36:17 Copied the reply from yukiy@:
yukiy 2017/09/25 08:59:05 As we chatted, avoid_double_hash_navigation logic
+ elif temperature == HOT:
+ if (previous_page is not None and
+ previous_page.url == page.url and
+ previous_page.cache_temperature != ANY):
+ if previous_page.cache_temperature == COLD:
+ WarmCache(page, browser)
+ else:
+ if '#' in page.url:
+ # Navigate to inexistent URL to avoid in-page hash navigation.
+ # Note: Unlike PCv1, PCv2 iterates the same URL for different cache
+ # configurations. This may issue blink in-page hash navigations,
+ # which isn't intended here.
+ with MarkTelemetryInternal(browser, 'avoid_double_hash_navigation'):
+ tab = browser.tabs[0]
+ tab.Navigate("http://does.not.exist")
+ tab.WaitForDocumentReadyStateToBeComplete()
+ else:
+ ClearCacheAndData(browser, page.url)
+ WarmCache(page, browser)
shimazu 2017/09/25 02:30:35 We need to stop workers for each WarmCache() since
yukiy 2017/09/25 06:28:37 I will do this with avoid_double_hash_navigation :
yukiy 2017/09/25 08:59:05 Done.
+ WarmCache(page, browser)
+ tab = browser.tabs[0]
+ tab.EnableServiceWorker()
+ tab.StopAllServiceWorkers()

Powered by Google App Engine
This is Rietveld 408576698