Ignore the pyc and eclipse project files.
[quix0rs-apt-p2p.git] / util.py
1 ## Copyright 2002-2003 Andrew Loewenstern, All Rights Reserved
2 # see LICENSE.txt for license information
3
4 def bucket_stats(l):
5     """given a list of khashmir instances, finds min, max, and average number of nodes in tables"""
6     max = avg = 0
7     min = None
8     def count(buckets):
9         c = 0
10         for bucket in buckets:
11             c = c + len(bucket.l)
12         return c
13     for node in l:
14         c = count(node.table.buckets)
15         if min == None:
16             min = c
17         elif c < min:
18             min = c
19         if c > max:
20             max = c
21         avg = avg + c
22     avg = avg / len(l)
23     return {'min':min, 'max':max, 'avg':avg}