Commit 75b04e70 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Merge plots common code to a decorator.

parent d9c3969f
...@@ -241,11 +241,9 @@ def drawBarDiagram(pdf, title, stat_list): ...@@ -241,11 +241,9 @@ def drawBarDiagram(pdf, title, stat_list):
pdf.savefig() pdf.savefig()
pylab.close() pylab.close()
def drawUseCasePerNumberOfUser(pdf, title, use_case_count_list, def drawPlotDecorator(xlabel, ylabel):
time_elapsed_list, is_single_plot=False): def inner(f):
""" def decorate(pdf, title, *args, **kwargs):
TODO: Merge with drawConcurrentUsersPlot?
"""
figure = pyplot.figure(figsize=(11.69, 8.29), frameon=False) figure = pyplot.figure(figsize=(11.69, 8.29), frameon=False)
figure.subplots_adjust(bottom=0.1, right=0.98, left=0.07, top=0.95) figure.subplots_adjust(bottom=0.1, right=0.98, left=0.07, top=0.95)
pyplot.title(title) pyplot.title(title)
...@@ -253,6 +251,35 @@ def drawUseCasePerNumberOfUser(pdf, title, use_case_count_list, ...@@ -253,6 +251,35 @@ def drawUseCasePerNumberOfUser(pdf, title, use_case_count_list,
axes = figure.add_subplot(111) axes = figure.add_subplot(111)
x_major, x_minor, y_major, y_minor = f(axes, *args, **kwargs)
axes.xaxis.set_major_locator(x_major)
if x_minor:
axes.xaxis.set_minor_locator(x_minor)
axes.xaxis.grid(True, 'minor')
axes.yaxis.set_major_locator(y_major)
if y_minor:
axes.yaxis.set_minor_locator(y_minor)
axes.yaxis.grid(True, 'minor')
axes.legend(loc=0)
axes.set_xlabel(xlabel)
axes.set_ylabel(ylabel)
pdf.savefig()
pylab.close()
return decorate
return inner
@drawPlotDecorator(xlabel='Time elapsed (in minutes)',
ylabel='Use cases')
def drawUseCasePerNumberOfUserPlot(axes,
use_case_count_list,
time_elapsed_list,
is_single_plot=False):
def get_cum_stat(stat_list): def get_cum_stat(stat_list):
cum_min_list = [] cum_min_list = []
cum_min = 0 cum_min = 0
...@@ -307,30 +334,16 @@ def drawUseCasePerNumberOfUser(pdf, title, use_case_count_list, ...@@ -307,30 +334,16 @@ def drawUseCasePerNumberOfUser(pdf, title, use_case_count_list,
axes.plot(time_cum_max_list, use_case_cum_max_list, 'gs-', label='Maximum') axes.plot(time_cum_max_list, use_case_cum_max_list, 'gs-', label='Maximum')
use_case_count_max = use_case_count_list[0].maximum use_case_count_max = use_case_count_list[0].maximum
axes.yaxis.set_major_locator(ticker.MultipleLocator(use_case_count_max * 2))
axes.yaxis.set_minor_locator(ticker.MultipleLocator(use_case_count_max))
axes.yaxis.grid(True, 'minor')
# TODO: Must be dynamic... # TODO: Must be dynamic...
axes.xaxis.set_major_locator(ticker.MultipleLocator(120)) return (ticker.MultipleLocator(120),
axes.xaxis.set_minor_locator(ticker.MultipleLocator(15)) ticker.MultipleLocator(15),
axes.xaxis.grid(True, 'minor') ticker.MultipleLocator(use_case_count_max * 2),
ticker.MultipleLocator(use_case_count_max))
axes.legend(loc=0)
axes.set_xlabel('Time elapsed (in minutes)') @drawPlotDecorator(xlabel='Concurrent users',
axes.set_ylabel('Use cases') ylabel='Seconds')
def drawConcurrentUsersPlot(axes, nb_users_list, stat_list):
pdf.savefig()
pylab.close()
def drawConcurrentUsersPlot(pdf, title, nb_users_list, stat_list):
figure = pyplot.figure(figsize=(11.69, 8.29), frameon=False)
figure.subplots_adjust(bottom=0.1, right=0.98, left=0.07, top=0.95)
pyplot.title(title)
pyplot.grid(True, linewidth=1.5)
axes = figure.add_subplot(111)
min_array = numpy.array([stat.minimum for stat in stat_list]) min_array = numpy.array([stat.minimum for stat in stat_list])
mean_array = numpy.array([stat.mean for stat in stat_list]) mean_array = numpy.array([stat.mean for stat in stat_list])
max_array = numpy.array([stat.maximum for stat in stat_list]) max_array = numpy.array([stat.maximum for stat in stat_list])
...@@ -353,20 +366,11 @@ def drawConcurrentUsersPlot(pdf, title, nb_users_list, stat_list): ...@@ -353,20 +366,11 @@ def drawConcurrentUsersPlot(pdf, title, nb_users_list, stat_list):
axes.plot(nb_users_list, max_array, 'gs-', label='Maximum') axes.plot(nb_users_list, max_array, 'gs-', label='Maximum')
axes.yaxis.set_major_locator(ticker.MultipleLocator(0.5))
axes.yaxis.set_minor_locator(ticker.MultipleLocator(0.25))
axes.yaxis.grid(True, 'minor')
axes.xaxis.set_major_locator(ticker.FixedLocator(nb_users_list))
axes.set_xticks(nb_users_list) axes.set_xticks(nb_users_list)
axes.legend(loc=0)
axes.set_xlabel('Concurrent users')
axes.set_ylabel('Seconds')
pyplot.xlim(xmin=nb_users_list[0]) pyplot.xlim(xmin=nb_users_list[0])
pdf.savefig()
pylab.close() return (ticker.FixedLocator(nb_users_list), None,
ticker.MultipleLocator(0.5), ticker.MultipleLocator(0.25))
from matplotlib.backends.backend_pdf import PdfPages from matplotlib.backends.backend_pdf import PdfPages
...@@ -416,7 +420,7 @@ def generateReport(): ...@@ -416,7 +420,7 @@ def generateReport():
for suite_name, (use_case_count_list, time_elapsed_list) in \ for suite_name, (use_case_count_list, time_elapsed_list) in \
use_case_dict.viewitems(): use_case_dict.viewitems():
title = "Scalability for %s with %d users" % (suite_name, nb_users) title = "Scalability for %s with %d users" % (suite_name, nb_users)
drawUseCasePerNumberOfUser(pdf, title, drawUseCasePerNumberOfUserPlot(pdf, title,
use_case_count_list, use_case_count_list,
time_elapsed_list, time_elapsed_list,
is_single_plot=(nb_users == 1)) is_single_plot=(nb_users == 1))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment