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

Side by Side Diff: my_reviews.py

Issue 19460002: Fix a corner case in my_reviews.py's median latency calculation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Get rietveld stats about the review you done, or forgot to do. 6 """Get rietveld stats about the review you done, or forgot to do.
7 7
8 Example: 8 Example:
9 - my_reviews.py -r me@chromium.org -Q for stats for last quarter. 9 - my_reviews.py -r me@chromium.org -Q for stats for last quarter.
10 """ 10 """
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return 0 79 return 0
80 return sum(self.latencies) / float(len(self.latencies)) 80 return sum(self.latencies) / float(len(self.latencies))
81 81
82 @property 82 @property
83 def median_latency(self): 83 def median_latency(self):
84 if not self.latencies: 84 if not self.latencies:
85 return 0 85 return 0
86 length = len(self.latencies) 86 length = len(self.latencies)
87 latencies = sorted(self.latencies) 87 latencies = sorted(self.latencies)
88 if (length & 1) == 0: 88 if (length & 1) == 0:
89 return (latencies[length/2] + latencies[length/2+1]) / 2. 89 return (latencies[length/2] + latencies[length/2-1]) / 2.
90 else: 90 else:
91 return latencies[length/2] 91 return latencies[length/2]
92 92
93 @property 93 @property
94 def percent_done(self): 94 def percent_done(self):
95 if not self.total: 95 if not self.total:
96 return 0 96 return 0
97 return self.actually_reviewed * 100. / self.total 97 return self.actually_reviewed * 100. / self.total
98 98
99 @property 99 @property
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 print_reviews( 352 print_reviews(
353 options.reviewer, 353 options.reviewer,
354 options.begin, 354 options.begin,
355 options.end, 355 options.end,
356 options.instance_url) 356 options.instance_url)
357 return 0 357 return 0
358 358
359 359
360 if __name__ == '__main__': 360 if __name__ == '__main__':
361 sys.exit(main()) 361 sys.exit(main())
OLDNEW
« 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