2015-07-11 07:51:30 +02:00
|
|
|
#!/usr/bin/env python
|
2018-06-16 16:12:18 +02:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
from __future__ import print_function
|
2008-05-08 21:09:55 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2009-01-03 08:54:30 +01:00
|
|
|
quantize = 100
|
|
|
|
max_rtt = 5000
|
2008-05-08 21:09:55 +02:00
|
|
|
|
|
|
|
f = open(sys.argv[1])
|
|
|
|
distribution = {}
|
|
|
|
num_messages = 0
|
|
|
|
|
|
|
|
for i in range(0, max_rtt, quantize):
|
2018-06-12 11:43:13 +02:00
|
|
|
distribution[i] = 0
|
2008-05-08 21:09:55 +02:00
|
|
|
|
|
|
|
for line in f:
|
2018-06-12 11:43:13 +02:00
|
|
|
time = int(line.split('\t')[1])
|
|
|
|
if (time < 0 or time > max_rtt - quantize):
|
|
|
|
continue
|
|
|
|
num_messages += 1
|
2018-10-20 00:05:18 +02:00
|
|
|
time //= quantize
|
2018-06-12 11:43:13 +02:00
|
|
|
time *= quantize
|
|
|
|
distribution[time] += 1
|
2008-05-08 21:09:55 +02:00
|
|
|
|
|
|
|
f = open('round_trip_distribution.log', 'w+')
|
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
for k, v in list(distribution.items()):
|
|
|
|
print('%f %d' % ((k + (quantize / 2)) / 1000.0, v), file=f)
|
|
|
|
f.close()
|
2008-05-08 21:09:55 +02:00
|
|
|
|
|
|
|
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)"
|
2013-12-20 07:19:50 +01:00
|
|
|
set xrange [0:*]
|
2008-05-08 21:09:55 +02:00
|
|
|
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()
|
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
os.system('gnuplot round_trip_distribution.gnuplot')
|