Plot previously collected metrics.
(
metadata: BenchmarkMetadata,
suite: BenchmarkSuite,
results_df: pd.DataFrame,
results_metadata: Collection[BenchmarkMetadata],
dest: Path,
)
| 73 | |
| 74 | |
| 75 | def plot( |
| 76 | metadata: BenchmarkMetadata, |
| 77 | suite: BenchmarkSuite, |
| 78 | results_df: pd.DataFrame, |
| 79 | results_metadata: Collection[BenchmarkMetadata], |
| 80 | dest: Path, |
| 81 | ) -> None: |
| 82 | """ Plot previously collected metrics. """ |
| 83 | for benchmark_set in suite.sets: |
| 84 | benchmark_set_df = benchmark_set.filter_metrics(results_df) |
| 85 | for file_key, file_df, file_plotters in group( |
| 86 | benchmark_set_df, benchmark_set.plots, results_metadata, benchmark_set.file_by |
| 87 | ): |
| 88 | row_groups = group(file_df, file_plotters, results_metadata, benchmark_set.row_by) |
| 89 | n_rows = len(row_groups) |
| 90 | n_columns = len( |
| 91 | group(file_df, file_plotters, results_metadata, benchmark_set.column_by) |
| 92 | ) |
| 93 | |
| 94 | width = 6 * n_columns |
| 95 | height = 4 * n_rows |
| 96 | fig, axes = plt.subplots( |
| 97 | ncols=n_columns, |
| 98 | nrows=n_rows, |
| 99 | figsize=(width, height), |
| 100 | squeeze=False, |
| 101 | dpi=100, |
| 102 | ) |
| 103 | |
| 104 | for row_axes, (row_key, row_df, row_plotters) in zip(axes, row_groups): |
| 105 | column_groups = group( |
| 106 | row_df, row_plotters, results_metadata, benchmark_set.column_by |
| 107 | ) |
| 108 | for column_ax, (column_key, column_df, column_plotters) in zip( |
| 109 | row_axes, column_groups |
| 110 | ): |
| 111 | (plotter,) = column_plotters |
| 112 | plotter.plot( |
| 113 | column_ax, |
| 114 | file_key, |
| 115 | column_key, |
| 116 | row_key, |
| 117 | benchmark_set.safe_line_by, |
| 118 | column_df, |
| 119 | results_metadata, |
| 120 | ) |
| 121 | |
| 122 | fig.tight_layout() |
| 123 | file_tokens = (benchmark_set.name,) + file_key |
| 124 | fig.savefig(dest / f"{'_'.join(file_tokens)}.png") |
| 125 | plt.close(fig) |
| 126 | |
| 127 | |
| 128 | def plot_from_argv() -> None: |
no test coverage detected
searching dependent graphs…