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

Function write_report

benchmarks/dart/benchmark_report.py:215–268  ·  view source on GitHub ↗
(payload: dict, results: dict, output_dir: str)

Source from the content-addressed store, hash-verified

213
214
215def write_report(payload: dict, results: dict, output_dir: str):
216 metadata = payload["metadata"]
217 report_path = os.path.join(output_dir, "README.md")
218 with open(report_path, "w", encoding="utf-8") as handle:
219 handle.write("# Fory Dart Benchmark\n\n")
220 handle.write(
221 "This benchmark compares serialization and deserialization throughput for "
222 "Apache Fory, Protocol Buffers, and JSON in Dart.\n\n"
223 )
224 handle.write("## Throughput Plot\n\n")
225 handle.write("![Throughput](throughput.png)\n\n")
226 handle.write("## Hardware and Runtime Info\n\n")
227 handle.write("| Key | Value |\n")
228 handle.write("| --- | --- |\n")
229 for key, value in system_info(metadata):
230 handle.write(f"| {key} | {value} |\n")
231
232 handle.write("\n## Throughput Results\n\n")
233 handle.write(
234 "| Datatype | Operation | Fory TPS | Protobuf TPS | JSON TPS | Fastest |\n"
235 )
236 handle.write("| --- | --- | ---: | ---: | ---: | --- |\n")
237 for data_type in DATA_TYPES:
238 operations = results.get(data_type, {})
239 if not operations:
240 continue
241 for operation in ["serialize", "deserialize"]:
242 values = {
243 serializer: operations.get(operation, {}).get(serializer)
244 for serializer in SERIALIZERS
245 }
246 handle.write(
247 f"| {DISPLAY_NAMES[data_type]} | {operation.capitalize()} | "
248 + " | ".join(
249 format_int(values[serializer]) for serializer in SERIALIZERS
250 )
251 + f" | {fastest_entry(values)} |\n"
252 )
253
254 handle.write("\n## Serialized Size (bytes)\n\n")
255 handle.write("| Datatype | Fory | Protobuf | JSON |\n")
256 handle.write("| --- | ---: | ---: | ---: |\n")
257 for data_type in DATA_TYPES:
258 sizes = payload["sizes"].get(data_type)
259 if sizes is None:
260 continue
261 fory_size = sizes.get("fory", "N/A")
262 protobuf_size = sizes.get("protobuf", "N/A")
263 json_size = sizes.get("json", "N/A")
264 handle.write(
265 f"| {DISPLAY_NAMES[data_type]} | {fory_size} | {protobuf_size} | {json_size} |\n"
266 )
267
268 format_markdown_with_prettier(report_path)
269
270
271def main() -> None:

Callers 1

mainFunction · 0.70

Calls 7

system_infoFunction · 0.85
format_intFunction · 0.85
fastest_entryFunction · 0.85
writeMethod · 0.65
getMethod · 0.65
capitalizeMethod · 0.45

Tested by

no test coverage detected