-
Notifications
You must be signed in to change notification settings - Fork 4
/
plot_matplotlib.py
73 lines (63 loc) · 2.33 KB
/
plot_matplotlib.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import matplotlib.pyplot as pyplot
from matplotlib.backends import backend_pdf
def continuous_monitor_col(continuous_monitor, key):
"""
For a given key, returns a list of data from continuous monitor entries
corresponding to that key.
"""
return [data[key] for data in continuous_monitor]
def plot(cm_data, file_prefix, open_graphs, disks):
disk_utilization_params = ['{0} utilization'.format(disk) for disk in disks]
disk_params = (
disk_utilization_params +
['{0} write throughput'.format(disk) for disk in disks] +
['{0} read throughput'.format(disk) for disk in disks]
)
memory_params = [
'free heap memory',
'free off heap memory'
]
monotasks_params = [
'local running macrotasks',
'macrotasks in network',
'macrotasks in compute',
'macrotasks in disk',
'running macrotasks',
'gc fraction',
'outstanding network bytes'
]
utilization_params = [
'cpu utilization',
'bytes received',
'bytes transmitted',
'cpu system',
'gc fraction'
] + disk_utilization_params
def plot_params(params_to_plot, title):
"""
Creates a matplotlib graph using continuous monitor data.
Time is the x axis and data corresponding to each parameter is used to
generate a new line on the line graph.
"""
pyplot.figure(title)
pyplot.title(title)
pyplot.grid(b=True, which='both')
times = continuous_monitor_col(cm_data, key='time')
for key in params_to_plot:
pyplot.plot(times, continuous_monitor_col(cm_data, key), label=key)
legend = pyplot.legend(loc='center left', bbox_to_anchor=(1, 0.5))
pdf_filepath = '{0}_{1}_graphs.pdf'.format(file_prefix, title.lower().replace(' ', '_'))
with backend_pdf.PdfPages(pdf_filepath) as pdf:
pdf.savefig(additional_artists=[legend], bbox_inches='tight')
plot_params(disk_params, title='Disk Utilization')
plot_params(memory_params, title='Memory')
plot_params(monotasks_params, title='Monotasks')
plot_params(utilization_params, title='Utilization')
for disk in disks:
disk_params = ['{0} running disk monotasks'.format(disk),
'{0} write throughput'.format(disk),
'{0} read throughput'.format(disk),
'{0} utilization'.format(disk)]
plot_params(disk_params, title='{0} Utilization'.format(disk))
if open_graphs:
pyplot.show()