Build a performance DataFrame summarizing queue metrics grouped by source_id. Returns a tuple of (perf_df, cmd_to_op_df) where cmd_to_op_df is needed for unmapped op tracking.
(tables: Tables)
| 123 | |
| 124 | |
| 125 | def build_perf_df(tables: Tables) -> tuple[pd.DataFrame, pd.DataFrame]: |
| 126 | """ |
| 127 | Build a performance DataFrame summarizing queue metrics grouped by source_id. |
| 128 | Returns a tuple of (perf_df, cmd_to_op_df) where cmd_to_op_df is needed for unmapped op tracking. |
| 129 | """ |
| 130 | tables.queue["cmd_id"] = tables.queue.index |
| 131 | |
| 132 | excluded = {"optimised_id", "scheduled_id", "offset"} |
| 133 | col_funcs: Dict[str, Agg] = { |
| 134 | c: "sum" for c in tables.queue.columns if c not in excluded |
| 135 | } |
| 136 | |
| 137 | col_funcs.update({"cmdstream_id": list_unique, "cmd_id": list_unique}) |
| 138 | |
| 139 | cmd_to_op_df = tables.queue.groupby(COMPILER_OP_ID).agg(col_funcs).reset_index() |
| 140 | |
| 141 | opt_df = ( |
| 142 | pd.merge(tables.perf[["id", "source_id"]], tables.group, on="id", how="left") |
| 143 | .rename(columns={"id": COMPILER_OP_ID}) |
| 144 | .merge(cmd_to_op_df, on=COMPILER_OP_ID, how="inner") |
| 145 | ) |
| 146 | |
| 147 | exclude_columns = ["source_id"] |
| 148 | src_col_funcs: Dict[str, Agg] = { |
| 149 | col: "sum" for col in opt_df.columns if col not in exclude_columns |
| 150 | } |
| 151 | src_col_funcs[COMPILER_OP_ID] = list_unique |
| 152 | |
| 153 | perf_df = opt_df.groupby("source_id").agg(src_col_funcs).reset_index() |
| 154 | |
| 155 | return perf_df, cmd_to_op_df |
| 156 | |
| 157 | |
| 158 | def check_unmapped_ops( |
no test coverage detected