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

Function plot_group

benchmarks/java/benchmark_report.py:163–209  ·  view source on GitHub ↗
(ax, results: dict, datatype: str)

Source from the content-addressed store, hash-verified

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

Callers 1

render_plotFunction · 0.70

Calls 7

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

Tested by

no test coverage detected