(ax, datatype)
| 187 | |
| 188 | |
| 189 | def plot_throughput_grid_subplot(ax, datatype): |
| 190 | if datatype not in data: |
| 191 | ax.set_title(f"{format_datatype_table_label(datatype)}\nNo Data") |
| 192 | ax.axis("off") |
| 193 | return |
| 194 | |
| 195 | available_libs = [ |
| 196 | lib |
| 197 | for lib in SERIALIZER_ORDER |
| 198 | if any( |
| 199 | data[datatype][operation].get(lib, 0) > 0 |
| 200 | for operation in ["serialize", "deserialize"] |
| 201 | ) |
| 202 | ] |
| 203 | if not available_libs: |
| 204 | ax.set_title(f"{format_datatype_table_label(datatype)}\nNo Data") |
| 205 | ax.axis("off") |
| 206 | return |
| 207 | |
| 208 | operations = ["serialize", "deserialize"] |
| 209 | x = GROUP_X |
| 210 | for idx, lib in enumerate(available_libs): |
| 211 | times = [data[datatype][operation].get(lib, 0) for operation in operations] |
| 212 | throughput = [1e9 / value if value > 0 else 0 for value in times] |
| 213 | offset = serializer_offset(idx, len(available_libs)) |
| 214 | ax.bar( |
| 215 | x + offset, |
| 216 | throughput, |
| 217 | GROUP_BAR_WIDTH, |
| 218 | label=SERIALIZER_LABELS[lib], |
| 219 | color=COLORS[lib], |
| 220 | edgecolor=BAR_EDGE_COLOR, |
| 221 | linewidth=0.8, |
| 222 | ) |
| 223 | |
| 224 | max_tps = max( |
| 225 | 1e9 / data[datatype][operation][lib] |
| 226 | for operation in operations |
| 227 | for lib in available_libs |
| 228 | if data[datatype][operation].get(lib, 0) > 0 |
| 229 | ) |
| 230 | ax.set_ylim(0, max_tps * 1.12) |
| 231 | ax.set_title(format_datatype_table_label(datatype), pad=8) |
| 232 | set_grouped_operation_axis(ax) |
| 233 | style_throughput_axis(ax) |
| 234 | ax.yaxis.set_major_formatter(FuncFormatter(format_tps_tick)) |
| 235 | add_compact_legend(ax) |
| 236 | |
| 237 | |
| 238 | fig, axes = plt.subplots(2, 3, figsize=(16.5, 9.0)) |
no test coverage detected