Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
python autobench grapher
from optparse import OptionParser
import sys
from pylab import *
parser = OptionParser()
parser.add_option('-f', '--file', dest = "filenames", help = "files devided by comma")
parser.add_option("-l", "--legend", dest = "legend", help = "legend for plots")
(options, args) = parser.parse_args()
input_files = options.filenames.split(',')
number_of_variants = len(input_files)
legends_name = options.legend.split(',')
datas = []
colors = ['green', 'blue', 'red']
# dem_req_rate -- Attempted request rate
# avg_rep_rate -- Average response time
cols_name = {'dem_req_rate': 0, 'req_rate': 1, 'con_rate': 2, 'min_rep_rate': 3, 'avg_rep_rate': 4, 'max_rep_rate': 5, 'stddev_rep_rate': 6, 'resp_time': 7, 'net_io': 8, 'errors': 9}
for input_file in input_files:
data = []
for line in open(input_file, 'r').readlines():
data.append(line.split())
data.pop(0)
datas.append(map(lambda column: map(lambda x: float(x), column), zip(*data)))
legend_loc = 4
legend_ncol = 3
legend_bbox_to_anchor = (0., 1.06, 1., .106)
# Reply rate
figure(0)
legends = []
for i in range(number_of_variants):
data = datas[i]
this_plot = plot(data[cols_name['dem_req_rate']], data[cols_name['avg_rep_rate']], colors[i], label = legends_name[i])
legends.append(this_plot)
legend(bbox_to_anchor=legend_bbox_to_anchor, loc=legend_loc, ncol=legend_ncol, mode="expand", borderaxespad=0.)
xlabel('Attempted request rate')
ylabel('Average reply rate')
title('Average reply rate')
grid(True)
# Attempted request rate
figure(1)
for i in range(number_of_variants):
data = datas[i]
plot(data[cols_name['dem_req_rate']], data[cols_name['resp_time']], colors[i], label = legends_name[i])
legend(bbox_to_anchor=legend_bbox_to_anchor, loc=legend_loc, ncol=legend_ncol, mode="expand", borderaxespad=0.)
xlabel('Attempted request rate')
ylabel('Response time')
title('Average response time (in ms)')
grid(True)
# Errors
figure(2)
for i in range(number_of_variants):
data = datas[i]
plot(data[cols_name['dem_req_rate']], data[cols_name['errors']], colors[i], label = legends_name[i])
legend(bbox_to_anchor=legend_bbox_to_anchor, loc=legend_loc, ncol=legend_ncol, mode="expand", borderaxespad=0.)
xlabel('Attempted request rate')
ylabel('Number of errors')
title('Errors')
grid(True)
# Standart deviation
figure(3)
for i in range(number_of_variants):
data = datas[i]
plot(data[cols_name['dem_req_rate']], data[cols_name['stddev_rep_rate']], colors[i], label = legends_name[i])
legend(bbox_to_anchor=legend_bbox_to_anchor, loc=legend_loc, ncol=legend_ncol, mode="expand", borderaxespad=0.)
xlabel('Attempted request rate')
ylabel('Standart deviation')
title('Standart deviation')
grid(True)
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment