-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.py
99 lines (81 loc) · 3.53 KB
/
graph.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
#
# Copyright (c) 2010-2012 Corey Goldberg (corey@goldb.org)
# License: GNU LGPLv3
#
# This file is part of Multi-Mechanize | Performance Test Framework
#
import sys
try:
import matplotlib
matplotlib.use('Agg') # use a non-GUI backend
from pylab import *
except ImportError:
print 'ERROR: can not import Matplotlib. install Matplotlib to generate graphs'
# response time graph for raw data
def resp_graph_raw(nested_resp_list, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Response Time (secs)' , size='x-small')
ax.grid(True, color='#666666')
xticks(size='x-small')
yticks(size='x-small')
x_seq = [item[0] for item in nested_resp_list]
y_seq = [item[1] for item in nested_resp_list]
ax.plot(x_seq, y_seq,
color='blue', linestyle='-', linewidth=0.0, marker='o',
markeredgecolor='blue', markerfacecolor='blue', markersize=2.0)
ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
savefig(dir + image_name)
# response time graph for bucketed data
def resp_graph(avg_resptime_points_dict, percentile_80_resptime_points_dict, percentile_90_resptime_points_dict, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Response Time (secs)' , size='x-small')
ax.grid(True, color='#666666')
xticks(size='x-small')
yticks(size='x-small')
x_seq = sorted(avg_resptime_points_dict.keys())
y_seq = [avg_resptime_points_dict[x] for x in x_seq]
ax.plot(x_seq, y_seq,
color='green', linestyle='-', linewidth=0.75, marker='o',
markeredgecolor='green', markerfacecolor='yellow', markersize=2.0)
x_seq = sorted(percentile_80_resptime_points_dict.keys())
y_seq = [percentile_80_resptime_points_dict[x] for x in x_seq]
ax.plot(x_seq, y_seq,
color='orange', linestyle='-', linewidth=0.75, marker='o',
markeredgecolor='orange', markerfacecolor='yellow', markersize=2.0)
x_seq = sorted(percentile_90_resptime_points_dict.keys())
y_seq = [percentile_90_resptime_points_dict[x] for x in x_seq]
ax.plot(x_seq, y_seq,
color='purple', linestyle='-', linewidth=0.75, marker='o',
markeredgecolor='purple', markerfacecolor='yellow', markersize=2.0)
ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
legend_lines = reversed(ax.get_lines()[:3])
ax.legend(
legend_lines,
('90pct', '80pct', 'Avg'),
loc='best',
handlelength=1,
borderpad=1,
prop=matplotlib.font_manager.FontProperties(size='xx-small')
)
savefig(dir + image_name)
# throughput graph
def tp_graph(throughputs_dict, image_name, dir='./'):
fig = figure(figsize=(8, 3.3)) # image dimensions
ax = fig.add_subplot(111)
ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
ax.set_ylabel('Transactions Per Second (count)' , size='x-small')
ax.grid(True, color='#666666')
xticks(size='x-small')
yticks(size='x-small')
x_seq = sorted(throughputs_dict.keys())
y_seq = [throughputs_dict[x] for x in x_seq]
ax.plot(x_seq, y_seq,
color='red', linestyle='-', linewidth=0.75, marker='o',
markeredgecolor='red', markerfacecolor='yellow', markersize=2.0)
ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
savefig(dir + image_name)