def extract_usage(db_obj, trace_id_rows, fill_none=True, factor=1.0, mean=False): """Takes a list of lists of trace_is and produces a list of lists of results corresponding to them. Args: - db_obj: DBManager object connted to a db where the results will be pulled from. """ exp_rows = [] my = ResultTrace() res_type = "usage" if mean: res_type = "usage_mean" for row in trace_id_rows: new_row = [] exp_rows.append(new_row) for trace_id in row: exp = ExperimentDefinition() exp.load(db_obj, trace_id) result = my._get_utilization_result() if exp.is_analysis_done(): result.load(db_obj, trace_id, res_type) else: result._set("utilization", 0) result._set("waste", 0) result._set("corrected_utilization", 0) result.apply_factor(factor) new_row.append(result) return exp_rows
def extract_results(db_obj, trace_id_rows_colors, result_type, factor=None, fill_none=True, second_pass=False): """Takes a list of lists of trace_is and produces a list of lists of results corresponding to them. Args: - db_obj: DBManager object connted to a db where the results will be pulled from. - trace_id_rows_colors: list of lists of integers as trace_ids of experiments. - result_type: string indentifying which type of result are we pulling. It correspond to the type of the NumericStats stored in db_obj. Returns: a list of lists of same dimension of trace_id_rows_colors, each element a NumericStats object corresponding to the result of that component. """ exp_rows = [] for row in trace_id_rows_colors: new_row = [] exp_rows.append(new_row) for trace_id in row: exp = ExperimentDefinition() exp.load(db_obj, trace_id) if exp.is_analysis_done(second_pass=second_pass): key = result_type + "_stats" result = NumericStats() result.load(db_obj, trace_id, key) if factor: result.apply_factor(factor) else: result = NumericStats() result.calculate([0, 0, 0]) if fill_none and result._get("median") is None: result = NumericStats() result.calculate([0, 0, 0]) new_row.append(result) return exp_rows