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

Unified Diff: tools/android/loading/sandwich_prefetch.py

Issue 2134763002: sandwich: Fixes a bug when served from cache request are before. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for landing Created 4 years, 5 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: tools/android/loading/sandwich_prefetch.py
diff --git a/tools/android/loading/sandwich_prefetch.py b/tools/android/loading/sandwich_prefetch.py
index 456c697b247b0be1bae2171c030e77d5caaec02f..22c9b0044b00f85ba9084d5462b09af9e66898f0 100644
--- a/tools/android/loading/sandwich_prefetch.py
+++ b/tools/android/loading/sandwich_prefetch.py
@@ -414,16 +414,14 @@ def _ProcessRunOutputDir(
run_output_verifier.VerifyTrace(trace)
logging.info('extracting metrics from trace: %s', trace_path)
- served_from_network_bytes = 0
- served_from_cache_bytes = 0
- urls_hitting_network = set()
+
+ # Gather response size per URLs.
response_sizes = {}
for request in sandwich_utils.FilterOutDataAndIncompleteRequests(
trace.request_track.GetEvents()):
# Ignore requests served from the blink's cache.
if request.served_from_cache:
continue
- urls_hitting_network.add(request.url)
if request.from_disk_cache:
if request.url in cached_encoded_data_lengths:
response_size = cached_encoded_data_lengths[request.url]
@@ -433,13 +431,27 @@ def _ProcessRunOutputDir(
# load.
logging.warning('Looks like could be served from memory cache: %s',
request.url)
- response_size = response_sizes[request.url]
- served_from_cache_bytes += response_size
+ if request.url in response_sizes:
+ response_size = response_sizes[request.url]
else:
response_size = request.GetResponseTransportLength()
- served_from_network_bytes += response_size
response_sizes[request.url] = response_size
+ # Sums the served from cache/network bytes.
+ served_from_network_bytes = 0
+ served_from_cache_bytes = 0
+ urls_hitting_network = set()
+ for request in sandwich_utils.FilterOutDataAndIncompleteRequests(
+ trace.request_track.GetEvents()):
+ # Ignore requests served from the blink's cache.
+ if request.served_from_cache:
+ continue
+ urls_hitting_network.add(request.url)
+ if request.from_disk_cache:
+ served_from_cache_bytes += response_sizes[request.url]
+ else:
+ served_from_network_bytes += response_sizes[request.url]
+
# Make sure the served from blink's cache requests have at least one
# corresponding request that was not served from the blink's cache.
for request in sandwich_utils.FilterOutDataAndIncompleteRequests(
« 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