premiere-libtorrent/parse_dht_log.py

47 lines
974 B
Python
Raw Normal View History

import sys
import os
f = open(sys.argv[1])
histogram = {}
for i in xrange(0, 50): histogram[i] = 0
2008-05-09 18:21:09 +02:00
counter = 0;
for line in f:
counter += 1
if counter % 1000 == 0:
print '\r%d' % counter,
try:
if not 'distance:' in line: continue;
l = line.split(' ')
d = int(l[4])
histogram[d] += 1
except:
print line.split(' ')
out = open('dht_announce_distribution.dat', 'w+')
for k,v in histogram.items():
print >>out, '%d %d' % (k, v)
out.close()
out = open('dht_announce_distribution.gnuplot', 'w+')
out.write('''
2008-05-09 02:53:59 +02:00
set term png size 1200,700 small
set output "dht_announce_distribution.png"
set title "bucket # announces are made against relative to target node-id"
set ylabel "# of announces"
set style fill solid border -1 pattern 2
plot "dht_announce_distribution.dat" using 1:2 title "announces" with boxes
2008-05-09 02:53:59 +02:00
set terminal postscript
set output "dht_announce_distribution.ps"
replot
''')
out.close()
os.system('gnuplot dht_announce_distribution.gnuplot');