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

Function plot_group

benchmarks/swift/benchmark_report.py:162–208  ·  view source on GitHub ↗
(ax, results: dict, datatype: str)

Source from the content-addressed store, hash-verified

160
161
162def 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
211def 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