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

Function plot_throughput_grid_subplot

benchmarks/go/benchmark_report.py:221–270  ·  view source on GitHub ↗

Plot one datatype with Serialize/Deserialize operation groups.

(ax, results, datatype)

Source from the content-addressed store, hash-verified

219
220
221def plot_throughput_grid_subplot(ax, results, datatype):
222 """Plot one datatype with Serialize/Deserialize operation groups."""
223 if datatype not in results:
224 ax.text(0.5, 0.5, "No data", ha="center", va="center", transform=ax.transAxes)
225 ax.set_title(display_name(datatype))
226 return
227
228 available_serializers = [
229 serializer
230 for serializer in SERIALIZERS
231 if any(serializer in results[datatype].get(op, {}) for op in OPERATIONS)
232 ]
233 if not available_serializers:
234 ax.text(0.5, 0.5, "No data", ha="center", va="center", transform=ax.transAxes)
235 ax.set_title(display_name(datatype))
236 return
237
238 x = GROUP_X
239 offsets = [
240 serializer_offset(idx, len(available_serializers))
241 for idx in range(len(available_serializers))
242 ]
243
244 for serializer, offset in zip(available_serializers, offsets):
245 values = []
246 for operation in OPERATIONS:
247 ns_per_op = results[datatype].get(operation, {}).get(serializer)
248 values.append(1e9 / ns_per_op if ns_per_op else 0)
249 ax.bar(
250 [position + offset for position in x],
251 values,
252 GROUP_BAR_WIDTH,
253 label=serializer.title(),
254 color=COLORS.get(serializer, "#888888"),
255 edgecolor=BAR_EDGE_COLOR,
256 linewidth=0.8,
257 )
258
259 max_value = max(
260 1e9 / results[datatype][operation][serializer]
261 for operation in OPERATIONS
262 for serializer in available_serializers
263 if results[datatype].get(operation, {}).get(serializer)
264 )
265 ax.set_ylim(0, max_value * 1.12)
266 ax.set_title(display_name(datatype), pad=8)
267 set_grouped_operation_axis(ax)
268 style_throughput_axis(ax)
269 ax.yaxis.set_major_formatter(FuncFormatter(format_ops_tick))
270 add_compact_legend(ax)
271
272
273def generate_combined_plot(results, output_dir):

Callers 1

generate_combined_plotFunction · 0.70

Calls 10

serializer_offsetFunction · 0.90
style_throughput_axisFunction · 0.90
add_compact_legendFunction · 0.90
display_nameFunction · 0.85
anyFunction · 0.85
textMethod · 0.80
getMethod · 0.65
appendMethod · 0.45
titleMethod · 0.45

Tested by

no test coverage detected