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

Side by Side Diff: tools/android/loading/metrics.py

Issue 2021093002: clovis: Report the number and cost of DNS requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | tools/android/loading/metrics_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Descriptive metrics for Clovis. 5 """Descriptive metrics for Clovis.
6 6
7 When executed as a script, prints the amount of data attributed to Ads, and 7 When executed as a script, prints the amount of data attributed to Ads, and
8 shows a graph of the amount of data to download for a new visit to the same 8 shows a graph of the amount of data to download for a new visit to the same
9 page, with a given time interval. 9 page, with a given time interval.
10 """ 10 """
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 Returns: 99 Returns:
100 (uploaded_bytes (int), downloaded_bytes (int)) 100 (uploaded_bytes (int), downloaded_bytes (int))
101 """ 101 """
102 content_lens = ( 102 content_lens = (
103 content_classification_lens.ContentClassificationLens.WithRulesFiles( 103 content_classification_lens.ContentClassificationLens.WithRulesFiles(
104 trace, ad_rules_filename, tracking_rules_filename)) 104 trace, ad_rules_filename, tracking_rules_filename))
105 requests = content_lens.AdAndTrackingRequests() 105 requests = content_lens.AdAndTrackingRequests()
106 return TransferSize(requests) 106 return TransferSize(requests)
107 107
108 108
109 def DnsRequestsAndCost(trace):
110 """Returns the number and cost of DNS requests for a trace."""
111 requests = trace.request_track.GetEvents()
112 requests_with_dns = [r for r in requests if r.timing.dns_start != -1]
113 dns_requests_count = len(requests_with_dns)
114 dns_cost = sum(r.timing.dns_end - r.timing.dns_start
115 for r in requests_with_dns)
116 return (dns_requests_count, dns_cost)
117
118
109 def PlotTransferSizeVsTimeBetweenVisits(trace): 119 def PlotTransferSizeVsTimeBetweenVisits(trace):
110 times = [10, 60, 300, 600, 3600, 4 * 3600, 12 * 3600, 24 * 3600] 120 times = [10, 60, 300, 600, 3600, 4 * 3600, 12 * 3600, 24 * 3600]
111 labels = ['10s', '1m', '10m', '1h', '4h', '12h', '1d'] 121 labels = ['10s', '1m', '10m', '1h', '4h', '12h', '1d']
112 (_, total_downloaded) = TotalTransferSize(trace) 122 (_, total_downloaded) = TotalTransferSize(trace)
113 downloaded = [TransferredDataRevisit(trace, delta_t)[1] for delta_t in times] 123 downloaded = [TransferredDataRevisit(trace, delta_t)[1] for delta_t in times]
114 plt.figure() 124 plt.figure()
115 plt.title('Amount of data to download for a revisit - %s' % trace.url) 125 plt.title('Amount of data to download for a revisit - %s' % trace.url)
116 plt.xlabel('Time between visits (log)') 126 plt.xlabel('Time between visits (log)')
117 plt.ylabel('Amount of data (bytes)') 127 plt.ylabel('Amount of data (bytes)')
118 plt.plot(times, downloaded, 'k+--') 128 plt.plot(times, downloaded, 'k+--')
(...skipping 17 matching lines...) Expand all
136 if __name__ == '__main__': 146 if __name__ == '__main__':
137 import sys 147 import sys
138 from matplotlib import pylab as plt 148 from matplotlib import pylab as plt
139 import loading_trace 149 import loading_trace
140 if len(sys.argv) != 4: 150 if len(sys.argv) != 4:
141 print ( 151 print (
142 'Usage: %s trace_filename ad_rules_filename tracking_rules_filename' 152 'Usage: %s trace_filename ad_rules_filename tracking_rules_filename'
143 % sys.argv[0]) 153 % sys.argv[0])
144 sys.exit(0) 154 sys.exit(0)
145 main(*sys.argv[1:]) 155 main(*sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | tools/android/loading/metrics_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698