fixes bug where priorities where lost when force-rechecking.
[libtorrent.git] / parse_dht_rtt.py
blobb2fa5c2d9865741ec5d796b32a806f0178480f3d
1 #!/usr/bin/python
3 import sys
4 import os
6 quantize = 200
7 max_rtt = 10000
9 f = open(sys.argv[1])
10 distribution = {}
11 num_messages = 0
13 for i in range(0, max_rtt, quantize):
14 distribution[i] = 0
16 for line in f:
17 time = int(line.split('\t')[1])
18 if (time < 0 or time > max_rtt): continue
19 num_messages += 1
20 time /= quantize
21 time *= quantize
22 distribution[time] += 1
24 f = open('round_trip_distribution.log', 'w+')
26 for k, v in distribution.items():
27 print >>f, '%f %d' % ((k + (quantize / 2)) / 1000.0, v)
28 f.close();
30 f = open('round_trip_distribution.gnuplot', 'w+')
32 f.write('''
33 set term png size 1200,700
34 set title "Message round trip times"
35 set terminal postscript
36 set ylabel "# of requests"
37 set xlabel "Round trip time (seconds)"
38 set grid
39 set style fill solid border -1 pattern 2
40 set output "round_trip_distribution.ps"
41 set boxwidth %f
42 plot "round_trip_distribution.log" using 1:2 title "requests" with boxes
44 set terminal png small
45 set output "round_trip_distribution.png"
46 replot
47 ''' % (float(quantize) / 1000.0))
48 f.close()
50 os.system('gnuplot round_trip_distribution.gnuplot');