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

Function build_xlang_section

benchmarks/java/benchmark_report.py:251–290  ·  view source on GitHub ↗
(results: dict, image_name: str)

Source from the content-addressed store, hash-verified

249
250
251def build_xlang_section(results: dict, image_name: str) -> str:
252 lines = [
253 "## Xlang Benchmark\n\n",
254 "Run from `benchmarks/java/run.sh`. Raw JMH JSON stays under the ignored local "
255 "`benchmarks/java/reports/` directory; `throughput.png` and this xlang "
256 "section are synced into `docs/benchmarks/java/`.\n\n",
257 "```bash\n",
258 "cd benchmarks/java\n",
259 "./run.sh\n",
260 "```\n\n",
261 "JMH parameters: `-f 1 -wi 3 -i 3 -t 1 -w 3s -r 3s -bm thrpt -tu s`. "
262 "Higher throughput is better.\n\n",
263 f"![Java Xlang Serialization Throughput]({image_name})\n\n",
264 "| Data type | Operation | "
265 + " | ".join(
266 f"{serializer_title(serializer)} ops/sec" for serializer in SERIALIZER_ORDER
267 )
268 + " | Fastest |\n",
269 "|-----------|-----------|"
270 + "|".join("---:" for _ in SERIALIZER_ORDER)
271 + "|---------|\n",
272 ]
273
274 for datatype in DATATYPE_ORDER:
275 for operation in OPERATIONS:
276 values = {
277 serializer: results.get(datatype, {})
278 .get(operation, {})
279 .get(serializer, 0.0)
280 for serializer in SERIALIZER_ORDER
281 }
282 lines.append(
283 f"| {datatype_title(datatype)} | {operation.capitalize()} | "
284 + " | ".join(
285 format_table_value(values[serializer])
286 for serializer in SERIALIZER_ORDER
287 )
288 + f" | {winner_cell(values)} |\n"
289 )
290 return "".join(lines)
291
292
293def write_local_readme(output_dir: Path, section: str) -> Path:

Callers 1

mainFunction · 0.85

Calls 7

serializer_titleFunction · 0.85
format_table_valueFunction · 0.85
datatype_titleFunction · 0.70
winner_cellFunction · 0.70
getMethod · 0.65
appendMethod · 0.45
capitalizeMethod · 0.45

Tested by

no test coverage detected