def __init__(self, workload_scale, file_format, queries, ref_queries): time_list = [] ref_time_list = [] for query_name, results in queries.items(): if query_name in ref_queries: # We want to calculate the average and geomean of the query only if it is both # results and reference results for query_results in results[RESULT_LIST]: time_list.append(query_results[TIME_TAKEN]) ref_results = ref_queries[query_name] for ref_query_results in ref_results[RESULT_LIST]: ref_time_list.append(ref_query_results[TIME_TAKEN]) self.workload_name = '{0}({1})'.format( workload_scale[0][1].upper(), workload_scale[1][1]) self.file_format = '{0} / {1} / {2}'.format( file_format[0][1], file_format[1][1], file_format[2][1]) self.avg = calculate_avg(time_list) ref_avg = calculate_avg(ref_time_list) self.delta_avg = calculate_change(self.avg, ref_avg) self.geomean = calculate_geomean(time_list) ref_geomean = calculate_geomean(ref_time_list) self.delta_geomean = calculate_change(self.geomean, ref_geomean)
def calculate_geomean_wrapper(times): """Wrapper around calculate_geomean that returns 'N/A' if the collection is empty""" if len(times) == 0: return 'N/A' return calculate_geomean(times)