logging.info(" Done.")
+def table_merged_details(table, input_data):
+ """Generate the table(s) with algorithm: table_merged_details
+ specified in the specification file.
+
+ :param table: Table to generate.
+ :param input_data: Data to process.
+ :type table: pandas.Series
+ :type input_data: InputData
+ """
+
+ logging.info(" Generating the table {0} ...".
+ format(table.get("title", "")))
+
+ # Transform the data
+ data = input_data.filter_data(table)
+ data = input_data.merge_data(data)
+ data.sort_index(inplace=True)
+
+ suites = input_data.filter_data(table, data_set="suites")
+ suites = input_data.merge_data(suites)
+
+ # Prepare the header of the tables
+ header = list()
+ for column in table["columns"]:
+ header.append('"{0}"'.format(str(column["title"]).replace('"', '""')))
+
+ for _, suite in suites.iteritems():
+ # Generate data
+ suite_name = suite["name"]
+ table_lst = list()
+ for test in data.keys():
+ if data[test]["parent"] in suite_name:
+ row_lst = list()
+ for column in table["columns"]:
+ try:
+ col_data = str(data[test][column["data"].
+ split(" ")[1]]).replace('"', '""')
+ if column["data"].split(" ")[1] in ("vat-history",
+ "show-run"):
+ col_data = replace(col_data, " |br| ", "",
+ maxreplace=1)
+ col_data = " |prein| {0} |preout| ".\
+ format(col_data[:-5])
+ row_lst.append('"{0}"'.format(col_data))
+ except KeyError:
+ row_lst.append("No data")
+ table_lst.append(row_lst)
+
+ # Write the data to file
+ if table_lst:
+ file_name = "{0}_{1}{2}".format(table["output-file"], suite_name,
+ table["output-file-ext"])
+ logging.info(" Writing file: '{}'".format(file_name))
+ with open(file_name, "w") as file_handler:
+ file_handler.write(",".join(header) + "\n")
+ for item in table_lst:
+ file_handler.write(",".join(item) + "\n")
+
+ logging.info(" Done.")
+
+
def table_performance_improvements(table, input_data):
"""Generate the table(s) with algorithm: table_performance_improvements
specified in the specification file.
line_lst.append(item["data"])
elif isinstance(item["data"], float):
line_lst.append("{:.1f}".format(item["data"]))
+ elif item["data"] is None:
+ line_lst.append("")
file_handler.write(",".join(line_lst) + "\n")
logging.info(" Generating the table {0} ...".
val = tmpl_item[int(args[0])]
tbl_item.append({"data": val})
elif cmd == "data":
- job = args[0]
- operation = args[1]
+ jobs = args[0:-1]
+ operation = args[-1]
data_lst = list()
- for build in data[job]:
- try:
- data_lst.append(float(build[tmpl_item[0]]["throughput"]
- ["value"]) / 1000000)
- except (KeyError, TypeError):
- # No data, ignore
- pass
+ for job in jobs:
+ for build in data[job]:
+ try:
+ data_lst.append(float(build[tmpl_item[0]]
+ ["throughput"]["value"]))
+ except (KeyError, TypeError):
+ # No data, ignore
+ continue
if data_lst:
- tbl_item.append({"data": eval(operation)(data_lst)})
+ tbl_item.append({"data": (eval(operation)(data_lst)) /
+ 1000000})
+ else:
+ tbl_item.append({"data": None})
elif cmd == "operation":
operation = args[0]
try:
- nr1 = tbl_item[int(args[1])]["data"]
- nr2 = tbl_item[int(args[2])]["data"]
+ nr1 = float(tbl_item[int(args[1])]["data"])
+ nr2 = float(tbl_item[int(args[2])]["data"])
if nr1 and nr2:
tbl_item.append({"data": eval(operation)(nr1, nr2)})
else:
tbl_item.append({"data": None})
- except IndexError:
- logging.error("No data for {0}".format(tbl_item[0]))
+ except (IndexError, ValueError, TypeError):
+ logging.error("No data for {0}".format(tbl_item[1]["data"]))
tbl_item.append({"data": None})
continue
else:
with open(file_name, "w") as file_handler:
file_handler.write(",".join(header) + "\n")
for item in tbl_lst:
+ if isinstance(item[-1]["data"], float):
+ rel_change = round(item[-1]["data"], 1)
+ else:
+ rel_change = item[-1]["data"]
if "ndr_top" in file_name \
and "ndr" in item[1]["data"] \
- and item[-1]["data"] >= 10:
+ and rel_change >= 10.0:
_write_line_to_file(file_handler, item)
elif "pdr_top" in file_name \
and "pdr" in item[1]["data"] \
- and item[-1]["data"] >= 10:
+ and rel_change >= 10.0:
_write_line_to_file(file_handler, item)
elif "ndr_low" in file_name \
and "ndr" in item[1]["data"] \
- and item[-1]["data"] < 10:
+ and rel_change < 10.0:
_write_line_to_file(file_handler, item)
elif "pdr_low" in file_name \
and "pdr" in item[1]["data"] \
- and item[-1]["data"] < 10:
+ and rel_change < 10.0:
_write_line_to_file(file_handler, item)
logging.info(" Done.")