1 | #!/usr/bin/env python
|
---|
2 | #
|
---|
3 | # Copyright (c) 2010 Corey Goldberg (corey@goldb.org)
|
---|
4 | # License: GNU LGPLv3
|
---|
5 | #
|
---|
6 | # This file is part of Multi-Mechanize
|
---|
7 |
|
---|
8 |
|
---|
9 | import sys
|
---|
10 |
|
---|
11 | try:
|
---|
12 | import matplotlib
|
---|
13 | matplotlib.use('Agg') # use a non-GUI backend
|
---|
14 | from pylab import *
|
---|
15 | except ImportError:
|
---|
16 | print 'ERROR: can not import Matplotlib. install Matplotlib to generate graphs'
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 | # response time graph for raw data
|
---|
21 | def resp_graph_raw(nested_resp_list, image_name, dir='./'):
|
---|
22 | fig = figure(figsize=(8, 3.3)) # image dimensions
|
---|
23 | ax = fig.add_subplot(111)
|
---|
24 | ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
|
---|
25 | ax.set_ylabel('Response Time (secs)' , size='x-small')
|
---|
26 | ax.grid(True, color='#666666')
|
---|
27 | xticks(size='x-small')
|
---|
28 | yticks(size='x-small')
|
---|
29 | x_seq = [item[0] for item in nested_resp_list]
|
---|
30 | y_seq = [item[1] for item in nested_resp_list]
|
---|
31 | ax.plot(x_seq, y_seq,
|
---|
32 | color='blue', linestyle='-', linewidth=0.0, marker='o',
|
---|
33 | markeredgecolor='blue', markerfacecolor='blue', markersize=2.0)
|
---|
34 | ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
|
---|
35 | savefig(dir + image_name)
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | # response time graph for bucketed data
|
---|
40 | def resp_graph(avg_resptime_points_dict, percentile_80_resptime_points_dict, percentile_90_resptime_points_dict, image_name, dir='./'):
|
---|
41 | fig = figure(figsize=(8, 3.3)) # image dimensions
|
---|
42 | ax = fig.add_subplot(111)
|
---|
43 | ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
|
---|
44 | ax.set_ylabel('Response Time (secs)' , size='x-small')
|
---|
45 | ax.grid(True, color='#666666')
|
---|
46 | xticks(size='x-small')
|
---|
47 | yticks(size='x-small')
|
---|
48 |
|
---|
49 | x_seq = sorted(avg_resptime_points_dict.keys())
|
---|
50 | y_seq = [avg_resptime_points_dict[x] for x in x_seq]
|
---|
51 | ax.plot(x_seq, y_seq,
|
---|
52 | color='green', linestyle='-', linewidth=0.75, marker='o',
|
---|
53 | markeredgecolor='green', markerfacecolor='yellow', markersize=2.0)
|
---|
54 |
|
---|
55 | x_seq = sorted(percentile_80_resptime_points_dict.keys())
|
---|
56 | y_seq = [percentile_80_resptime_points_dict[x] for x in x_seq]
|
---|
57 | ax.plot(x_seq, y_seq,
|
---|
58 | color='orange', linestyle='-', linewidth=0.75, marker='o',
|
---|
59 | markeredgecolor='orange', markerfacecolor='yellow', markersize=2.0)
|
---|
60 |
|
---|
61 | x_seq = sorted(percentile_90_resptime_points_dict.keys())
|
---|
62 | y_seq = [percentile_90_resptime_points_dict[x] for x in x_seq]
|
---|
63 | ax.plot(x_seq, y_seq,
|
---|
64 | color='purple', linestyle='-', linewidth=0.75, marker='o',
|
---|
65 | markeredgecolor='purple', markerfacecolor='yellow', markersize=2.0)
|
---|
66 |
|
---|
67 | ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
|
---|
68 |
|
---|
69 | legend_lines = reversed(ax.get_lines()[:3])
|
---|
70 | ax.legend(
|
---|
71 | legend_lines,
|
---|
72 | ('90pct', '80pct', 'Avg'),
|
---|
73 | loc='best',
|
---|
74 | handlelength=1,
|
---|
75 | borderpad=1,
|
---|
76 | prop=matplotlib.font_manager.FontProperties(size='xx-small')
|
---|
77 | )
|
---|
78 |
|
---|
79 | savefig(dir + image_name)
|
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 | # throughput graph
|
---|
84 | def tp_graph(throughputs_dict, image_name, dir='./'):
|
---|
85 | fig = figure(figsize=(8, 3.3)) # image dimensions
|
---|
86 | ax = fig.add_subplot(111)
|
---|
87 | ax.set_xlabel('Elapsed Time In Test (secs)', size='x-small')
|
---|
88 | ax.set_ylabel('Transactions Per Second (count)' , size='x-small')
|
---|
89 | ax.grid(True, color='#666666')
|
---|
90 | xticks(size='x-small')
|
---|
91 | yticks(size='x-small')
|
---|
92 | x_seq = sorted(throughputs_dict.keys())
|
---|
93 | y_seq = [throughputs_dict[x] for x in x_seq]
|
---|
94 | ax.plot(x_seq, y_seq,
|
---|
95 | color='red', linestyle='-', linewidth=0.75, marker='o',
|
---|
96 | markeredgecolor='red', markerfacecolor='yellow', markersize=2.0)
|
---|
97 | ax.plot([0.0,], [0.0,], linewidth=0.0, markersize=0.0)
|
---|
98 | savefig(dir + image_name)
|
---|
99 | |
---|