2 # Copyright Arvid Norberg 2008. Use, modification and distribution is
3 # subject to the Boost Software License, Version 1.0. (See accompanying
4 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 lines
= open(sys
.argv
[1], 'rb').readlines()
10 #keys = ['send_buffer_utilization']
11 keys
= ['send_buffer_size', 'used_send_buffer', 'protocol_buffer']
12 #keys = ['send_buffer_alloc', 'send_buffer', 'allocate_buffer_alloc', 'allocate_buffer', 'protocol_buffer']
13 #keys = ['send_buffer_alloc', 'send_buffer', 'allocate_buffer_alloc', 'allocate_buffer', 'protocol_buffer', 'append_send_buffer']
15 average
= ['send_buffer_utilization', 'send_buffer_size', 'used_send_buffer']
16 average_interval
= 120000
21 time_limit
= long(sys
.argv
[2])
25 # <time(ms)> <key> <value>
27 # 16434 allocate_buffer: 17
31 average_accumulator
= 0
35 out
= open(k
+ '.dat', 'wb')
39 peak_out
= open(k
+ '_peak.dat', 'wb')
48 if time_limit
!= -1 and long(l
[0]) > time_limit
: break
52 while long(time
) > last_sample
+ average_interval
:
53 last_sample
= last_sample
+ average_interval
54 if average_samples
< 1: average_samples
= 1
55 print >>out
, '%d %f' % (last_sample
, average_accumulator
/ average_samples
)
56 print >>peak_out
, '%d %f' % (last_sample
, peak
)
57 average_accumulator
= 0
60 average_accumulator
= average_accumulator
+ float(value
)
61 average_samples
= average_samples
+ 1
62 if float(value
) > peak
: peak
= float(value
)
64 print >>out
, time
+ ' ' + value
,
71 out
= open('send_buffer.gnuplot', 'wb')
72 print >>out
, "set term png size 1200,700"
73 print >>out
, 'set output "send_buffer.png"'
74 print >>out
, 'set xrange [0:*]'
75 print >>out
, 'set xlabel "time (ms)"'
76 print >>out
, 'set ylabel "bytes (B)"'
77 print >>out
, "set style data lines"
78 print >>out
, "set key box"
82 print >>out
, ' "%s.dat" using 1:2 title "%s %d seconds average" with %s,' % (k
, k
, average_interval
/ 1000., render
),
83 print >>out
, ' "%s_peak.dat" using 1:2 title "%s %d seconds peak" with %s,' % (k
, k
, average_interval
/ 1000., render
),
85 print >>out
, ' "%s.dat" using 1:2 title "%s" with %s,' % (k
, k
, render
),
89 os
.system('gnuplot send_buffer.gnuplot')