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

Side by Side Diff: tools/android/loading/metrics_unittest.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 | « tools/android/loading/metrics.py ('k') | tools/android/loading/report.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 import copy 5 import copy
6 import unittest 6 import unittest
7 7
8 import metrics 8 import metrics
9 import request_track 9 import request_track
10 import test_utils 10 import test_utils
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 self._BODY_SIZE + self._RESPONSE_HEADERS_SIZE + cache_control_length, 65 self._BODY_SIZE + self._RESPONSE_HEADERS_SIZE + cache_control_length,
66 downloaded) 66 downloaded)
67 67
68 def testTransferSize(self): 68 def testTransferSize(self):
69 trace = self._MakeTrace() 69 trace = self._MakeTrace()
70 r = trace.request_track.GetEvents()[0] 70 r = trace.request_track.GetEvents()[0]
71 (_, downloaded) = metrics.TransferSize([r]) 71 (_, downloaded) = metrics.TransferSize([r])
72 self.assertEqual(self._BODY_SIZE + self._RESPONSE_HEADERS_SIZE, 72 self.assertEqual(self._BODY_SIZE + self._RESPONSE_HEADERS_SIZE,
73 downloaded) 73 downloaded)
74 74
75 def testDnsRequestsAndCost(self):
76 trace = self._MakeTrace()
77 (count, cost) = metrics.DnsRequestsAndCost(trace)
78 self.assertEqual(0, count)
79 self.assertEqual(0, cost)
80 r = trace.request_track.GetEvents()[0]
81 r.timing.dns_end = 12
82 r.timing.dns_start = 4
83 (count, cost) = metrics.DnsRequestsAndCost(trace)
84 self.assertEqual(1, count)
85 self.assertEqual(8, cost)
86
75 @classmethod 87 @classmethod
76 def _MakeTrace(cls): 88 def _MakeTrace(cls):
77 request = request_track.Request.FromJsonDict(copy.deepcopy(cls._REQUEST)) 89 request = request_track.Request.FromJsonDict(copy.deepcopy(cls._REQUEST))
78 return test_utils.LoadingTraceFromEvents([request]) 90 return test_utils.LoadingTraceFromEvents([request])
79 91
80 92
81 if __name__ == '__main__': 93 if __name__ == '__main__':
82 unittest.main() 94 unittest.main()
OLDNEW
« no previous file with comments | « tools/android/loading/metrics.py ('k') | tools/android/loading/report.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698