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()
11 print "usage: parse_disk_log.py logfile [seconds]"
14 keys
= ['write', 'read', 'hash', 'move', 'release', 'idle']
15 throughput_keys
= ['write', 'read']
24 quantization
= long(sys
.argv
[2]) * 1000
28 out
= open('disk_io.dat', 'wb')
29 out2
= open('disk_throughput.dat', 'wb')
35 for k
in keys
: state_timer
[k
] = 0
36 for k
in throughput_keys
: throughput
[k
] = 0
44 while new_time
> i
+ quantization
:
46 state_timer
[state
] += i
- time
48 for k
in keys
: print >>out
, state_timer
[k
],
50 for k
in throughput_keys
: print >>out2
, throughput
[k
] / 1000.,
52 for k
in keys
: state_timer
[k
] = 0
53 for k
in throughput_keys
: throughput
[k
] = 0
54 state_timer
[state
] += new_time
- time
57 if state
in throughput_keys
:
58 throughput
[state
] += long(l
[2])
64 out
= open('disk_io.gnuplot', 'wb')
65 print >>out
, "set term png size 1200,700"
67 print >>out
, 'set output "disk_throughput.png"'
68 print >>out
, 'set title "disk throughput per %s second(s)"' % (quantization
/ 1000)
69 print >>out
, 'set ylabel "throughput (kB)"'
72 for k
in throughput_keys
:
73 print >>out
, ' "disk_throughput.dat" using %d title "%s" with lines,' % (i
+ 1, throughput_keys
[i
]),
77 print >>out
, 'set output "disk_io.png"'
78 print >>out
, 'set ylabel "time (ms)"'
79 print >>out
, 'set xrange [0:*]'
80 print >>out
, 'set title "disk io utilization per %s second(s)"' % (quantization
/ 1000)
81 print >>out
, "set key box"
82 print >>out
, "set style data histogram"
83 print >>out
, "set style histogram rowstacked"
84 print >>out
, "set style fill solid"
89 print >>out
, ' "disk_io.dat" using %d title "%s",' % (i
+ 1, keys
[i
]),
94 os
.system('gnuplot disk_io.gnuplot');