|
25 | 25 | __all__ = [ |
26 | 26 | "generate_impl_summary_report", |
27 | 27 | "generate_performance_report", |
| 28 | + "generate_comparison_report", |
28 | 29 | ] |
29 | 30 |
|
30 | 31 |
|
@@ -216,6 +217,74 @@ def generate_performance_report( |
216 | 217 | generate_summary(df) |
217 | 218 |
|
218 | 219 |
|
| 220 | +def generate_comparison_report( |
| 221 | + conn: sqlalchemy.Engine, |
| 222 | + run_id: int, |
| 223 | + implementations: list[str], |
| 224 | + comparison_pairs: list[tuple[str, str]], |
| 225 | + headless=False, |
| 226 | +): |
| 227 | + """generate comparison report with median times for each benchmark""" |
| 228 | + if len(comparison_pairs) == 0: |
| 229 | + return |
| 230 | + |
| 231 | + legends = read_legends() |
| 232 | + |
| 233 | + if not headless: |
| 234 | + generate_header(conn, run_id) |
| 235 | + generate_legend(legends) |
| 236 | + |
| 237 | + columns = [ |
| 238 | + dm.Result.input_size_human.label("input_size"), |
| 239 | + dm.Result.benchmark, |
| 240 | + dm.Result.problem_preset, |
| 241 | + ] |
| 242 | + |
| 243 | + for impl in implementations: |
| 244 | + columns.append( |
| 245 | + func.ifnull( |
| 246 | + func.max( |
| 247 | + case( |
| 248 | + ( |
| 249 | + dm.Result.implementation == impl, |
| 250 | + dm.Result.median_exec_time, |
| 251 | + ), |
| 252 | + ) |
| 253 | + ), |
| 254 | + None, |
| 255 | + ).label(impl), |
| 256 | + ) |
| 257 | + |
| 258 | + sql = ( |
| 259 | + sqlalchemy.select(*columns) |
| 260 | + .group_by( |
| 261 | + dm.Result.benchmark, |
| 262 | + dm.Result.problem_preset, |
| 263 | + ) |
| 264 | + .where(dm.Result.run_id == run_id) |
| 265 | + ) |
| 266 | + |
| 267 | + df = pd.read_sql_query( |
| 268 | + sql=sql, |
| 269 | + con=conn.connect(), |
| 270 | + ) |
| 271 | + |
| 272 | + for index, row in df.iterrows(): |
| 273 | + for target, reference in comparison_pairs: |
| 274 | + if row[reference] == 0 or row[target] == 0: |
| 275 | + boost = "n/a" |
| 276 | + else: |
| 277 | + boost = ( |
| 278 | + str(round((row[target] / row[reference]) * 100, 2)) + "%" |
| 279 | + ) |
| 280 | + df.at[index, target + "_to_" + reference] = boost |
| 281 | + |
| 282 | + for impl in implementations: |
| 283 | + df = df.drop(impl, axis=1) |
| 284 | + |
| 285 | + generate_summary(df) |
| 286 | + |
| 287 | + |
219 | 288 | def get_failures_from_results( |
220 | 289 | results_db: Union[str, sqlalchemy.Engine] = "results.db", |
221 | 290 | run_id: int = None, |
|
0 commit comments