MCPcopy Create free account
hub / github.com/apache/fory / plot_throughput_grid_subplot

Function plot_throughput_grid_subplot

benchmarks/python/benchmark_report.py:160–209  ·  view source on GitHub ↗
(ax, data, datatype: str)

Source from the content-addressed store, hash-verified

158
159
160def plot_throughput_grid_subplot(ax, data, datatype: str):
161 if datatype not in data:
162 ax.set_title(f"{format_datatype_table_label(datatype)}\nNo Data")
163 ax.axis("off")
164 return
165
166 available_libs = [
167 lib
168 for lib in SERIALIZER_ORDER
169 if any(
170 data.get(datatype, {}).get(operation, {}).get(lib, 0) > 0
171 for operation in ["serialize", "deserialize"]
172 )
173 ]
174 if not available_libs:
175 ax.set_title(f"{format_datatype_table_label(datatype)}\nNo Data")
176 ax.axis("off")
177 return
178
179 operations = ["serialize", "deserialize"]
180 x = GROUP_X
181 for idx, lib in enumerate(available_libs):
182 times = [
183 data.get(datatype, {}).get(operation, {}).get(lib, 0)
184 for operation in operations
185 ]
186 tps = [1e9 / val if val > 0 else 0 for val in times]
187 offset = serializer_offset(idx, len(available_libs))
188 ax.bar(
189 x + offset,
190 tps,
191 GROUP_BAR_WIDTH,
192 label=SERIALIZER_LABELS.get(lib, lib),
193 color=COLORS.get(lib, "#999999"),
194 edgecolor=BAR_EDGE_COLOR,
195 linewidth=0.8,
196 )
197
198 max_tps = max(
199 1e9 / data[datatype][operation][lib]
200 for operation in operations
201 for lib in available_libs
202 if data.get(datatype, {}).get(operation, {}).get(lib, 0) > 0
203 )
204 ax.set_ylim(0, max_tps * 1.12)
205 ax.set_title(format_datatype_table_label(datatype), pad=8)
206 set_grouped_operation_axis(ax)
207 style_throughput_axis(ax)
208 ax.yaxis.set_major_formatter(FuncFormatter(format_tps_tick))
209 add_compact_legend(ax)
210
211
212def generate_plots(data, output_dir: Path):

Callers 1

generate_plotsFunction · 0.70

Calls 7

serializer_offsetFunction · 0.90
style_throughput_axisFunction · 0.90
add_compact_legendFunction · 0.90
anyFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected