X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_plots.py;h=b7fd420aa263e9462344fce33b2070a12c065a53;hp=5580cbdf1ca0abbf603c6f8d4f66da0e7f17354a;hb=482bb432e9607bce6cb92d41bf9e299c0e2fc288;hpb=0f06aa38489e4242ee2b51bc23f79682a8f658f9 diff --git a/resources/tools/presentation/generator_plots.py b/resources/tools/presentation/generator_plots.py index 5580cbdf1c..b7fd420aa2 100644 --- a/resources/tools/presentation/generator_plots.py +++ b/resources/tools/presentation/generator_plots.py @@ -19,6 +19,7 @@ import logging import pandas as pd import plotly.offline as ploff import plotly.graph_objs as plgo + from plotly.exceptions import PlotlyError from utils import mean @@ -45,7 +46,7 @@ def generate_plots(spec, data): def plot_performance_box(plot, input_data): - """Generate the plot(s) with algorithm: table_detailed_test_results + """Generate the plot(s) with algorithm: plot_performance_box specified in the specification file. :param plot: Plot to generate. @@ -261,13 +262,16 @@ def plot_throughput_speedup_analysis(plot, input_data): except (KeyError, TypeError): pass + if not throughput: + logging.warning("No data for the plot '{}'". + format(plot.get("title", ""))) + return + for test_name, test_vals in throughput.items(): for key, test_val in test_vals.items(): if test_val: throughput[test_name][key] = sum(test_val) / len(test_val) - print(throughput) - names = ['1 core', '2 cores', '4 cores'] x_vals = list() y_vals_1 = list() @@ -276,7 +280,7 @@ def plot_throughput_speedup_analysis(plot, input_data): for test_name, test_vals in throughput.items(): if test_vals["1"]: - x_vals.append("-".join(test_name.split('-')[:-1])) + x_vals.append("-".join(test_name.split('-')[1:-1])) y_vals_1.append(1) if test_vals["2"]: y_vals_2.append( @@ -315,3 +319,73 @@ def plot_throughput_speedup_analysis(plot, input_data): return logging.info(" Done.") + + +def plot_http_server_performance_box(plot, input_data): + """Generate the plot(s) with algorithm: plot_http_server_performance_box + specified in the specification file. + + :param plot: Plot to generate. + :param input_data: Data to process. + :type plot: pandas.Series + :type input_data: InputData + """ + + logging.info(" Generating the plot {0} ...". + format(plot.get("title", ""))) + + # Transform the data + data = input_data.filter_data(plot) + if data is None: + logging.error("No data.") + return + + # Prepare the data for the plot + y_vals = dict() + for job in data: + for build in job: + for test in build: + if y_vals.get(test["name"], None) is None: + y_vals[test["name"]] = list() + try: + y_vals[test["name"]].append(test["result"]["value"]) + except (KeyError, TypeError): + y_vals[test["name"]].append(None) + + # Add None to the lists with missing data + max_len = 0 + for val in y_vals.values(): + if len(val) > max_len: + max_len = len(val) + for key, val in y_vals.items(): + if len(val) < max_len: + val.extend([None for _ in range(max_len - len(val))]) + + # Add plot traces + traces = list() + df = pd.DataFrame(y_vals) + df.head() + for i, col in enumerate(df.columns): + name = "{0}. {1}".format(i + 1, col.lower().replace('-cps', ''). + replace('-rps', '')) + traces.append(plgo.Box(x=[str(i + 1) + '.'] * len(df[col]), + y=df[col], + name=name, + **plot["traces"])) + try: + # Create plot + plpl = plgo.Figure(data=traces, layout=plot["layout"]) + + # Export Plot + logging.info(" Writing file '{0}{1}'.". + format(plot["output-file"], plot["output-file-type"])) + ploff.plot(plpl, + show_link=False, auto_open=False, + filename='{0}{1}'.format(plot["output-file"], + plot["output-file-type"])) + except PlotlyError as err: + logging.error(" Finished with error: {}". + format(str(err).replace("\n", " "))) + return + + logging.info(" Done.")