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

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

Issue 3013213002: Add methods for cache_temperature: ClearCache, WarmCache (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/page/cache_temperature.py
diff --git a/telemetry/telemetry/page/cache_temperature.py b/telemetry/telemetry/page/cache_temperature.py
index 749ab864149ba1460d56e85b5ea6c352d785d299..1937da07ee041db7f71a4546d80f372a3fb2b0c4 100644
--- a/telemetry/telemetry/page/cache_temperature.py
+++ b/telemetry/telemetry/page/cache_temperature.py
@@ -54,37 +54,43 @@ class MarkTelemetryInternal(object):
"console.timeEnd({{ marker }});", marker=marker)
return True
+def ClearCache(browser):
+ with MarkTelemetryInternal(browser, 'clear_cache'):
+ any_tab = browser.tabs[0]
shimazu 2017/09/19 09:37:31 nit: |tab| seems enough.
yukiy 2017/09/21 08:23:44 Done.
+ any_tab.ClearCache(force=True)
+
+def AvoidDoubleHashNavigation(page, browser):
+ if '#' in page.url:
shimazu 2017/09/19 09:37:31 nit: The opposite condition might be better to red
kouhei (in TOK) 2017/09/19 09:38:51 Would you mind keeping AvoidDoubleHashNavigation a
nednguyen 2017/09/19 09:50:05 +1. If the purpose is to make the EnsurePageCacheT
yukiy 2017/09/21 08:23:44 Done.
yukiy 2017/09/21 08:23:44 I chatted with kouhei@, and decided not to do this
yukiy 2017/09/21 08:23:44 Acknowledged.
+ # 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()
+
+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()
+ tab.Navigate("about:blank")
+ tab.WaitForDocumentReadyStateToBeComplete()
+
def EnsurePageCacheTemperature(page, browser, previous_page=None):
temperature = page.cache_temperature
logging.info('PageCacheTemperature: %s', temperature)
-
if temperature == ANY:
return
-
if temperature == COLD:
- with MarkTelemetryInternal(browser, 'clear_cache'):
- any_tab = browser.tabs[0]
- any_tab.ClearCache(force=True)
+ ClearCache(browser)
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)):
- 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()
+ AvoidDoubleHashNavigation(page, browser)
return
-
- with MarkTelemetryInternal(browser, 'warm_cache'):
- tab = browser.tabs[0]
- tab.Navigate(page.url)
- py_utils.WaitFor(tab.HasReachedQuiescence, 60)
- tab.WaitForDocumentReadyStateToBeComplete()
- tab.Navigate("about:blank")
- tab.WaitForDocumentReadyStateToBeComplete()
+ WarmCache(page, browser)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698