(ax, results: dict, datatype: str)
| 160 | |
| 161 | |
| 162 | def plot_group(ax, results: dict, datatype: str) -> None: |
| 163 | if datatype not in results: |
| 164 | ax.set_title(f"{datatype_title(datatype)}\nNo Data") |
| 165 | ax.axis("off") |
| 166 | return |
| 167 | |
| 168 | available_serializers = [ |
| 169 | serializer |
| 170 | for serializer in SERIALIZER_ORDER |
| 171 | if any( |
| 172 | results.get(datatype, {}).get(operation, {}).get(serializer, 0.0) > 0 |
| 173 | for operation in OPERATIONS |
| 174 | ) |
| 175 | ] |
| 176 | if not available_serializers: |
| 177 | ax.set_title(f"{datatype_title(datatype)}\nNo Data") |
| 178 | ax.axis("off") |
| 179 | return |
| 180 | |
| 181 | x = GROUP_X |
| 182 | for index, serializer in enumerate(available_serializers): |
| 183 | values = [ |
| 184 | results.get(datatype, {}).get(operation, {}).get(serializer, 0.0) |
| 185 | for operation in OPERATIONS |
| 186 | ] |
| 187 | offset = serializer_offset(index, len(available_serializers)) |
| 188 | ax.bar( |
| 189 | x + offset, |
| 190 | values, |
| 191 | width=GROUP_BAR_WIDTH, |
| 192 | label=serializer, |
| 193 | color=COLORS.get(serializer, "#888888"), |
| 194 | edgecolor=BAR_EDGE_COLOR, |
| 195 | linewidth=0.8, |
| 196 | ) |
| 197 | |
| 198 | max_value = max( |
| 199 | results.get(datatype, {}).get(operation, {}).get(serializer, 0.0) |
| 200 | for operation in OPERATIONS |
| 201 | for serializer in available_serializers |
| 202 | ) |
| 203 | ax.set_ylim(0, max_value * 1.12) |
| 204 | ax.set_title(datatype_title(datatype), pad=8) |
| 205 | set_grouped_operation_axis(ax) |
| 206 | style_throughput_axis(ax) |
| 207 | ax.yaxis.set_major_formatter(FuncFormatter(format_tps_tick)) |
| 208 | add_compact_legend(ax) |
| 209 | |
| 210 | |
| 211 | def render_plot(results: dict, output_dir: str) -> str: |
no test coverage detected