-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_dht_rtt.py
executable file
·51 lines (39 loc) · 1.07 KB
/
parse_dht_rtt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env python
import sys
import os
quantize = 100
max_rtt = 5000
f = open(sys.argv[1])
distribution = {}
num_messages = 0
for i in range(0, max_rtt, quantize):
distribution[i] = 0
for line in f:
time = int(line.split('\t')[1])
if (time < 0 or time > max_rtt - quantize): continue
num_messages += 1
time /= quantize
time *= quantize
distribution[time] += 1
f = open('round_trip_distribution.log', 'w+')
for k, v in distribution.items():
print >>f, '%f %d' % ((k + (quantize / 2)) / 1000.0, v)
f.close();
f = open('round_trip_distribution.gnuplot', 'w+')
f.write('''
set term png size 1200,700
set title "Message round trip times"
set terminal postscript
set ylabel "# of requests"
set xlabel "Round trip time (seconds)"
set grid
set style fill solid border -1 pattern 2
set output "round_trip_distribution.ps"
set boxwidth %f
plot "round_trip_distribution.log" using 1:2 title "requests" with boxes
set terminal png small
set output "round_trip_distribution.png"
replot
''' % (float(quantize) / 1000.0))
f.close()
os.system('gnuplot round_trip_distribution.gnuplot');