MCPcopy Index your code
hub / github.com/python/cpython / format_markdown

Method format_markdown

Tools/picklebench/memory_dos_impact.py:800–821  ·  view source on GitHub ↗

Format results as markdown table.

(results: Dict[str, Dict[str, Any]])

Source from the content-addressed store, hash-verified

798
799 @staticmethod
800 def format_markdown(results: Dict[str, Dict[str, Any]]) -> str:
801 """Format results as markdown table."""
802 lines = []
803 lines.append("# Pickle Unpickling Benchmark Results\n")
804
805 for size_key, tests in results.items():
806 lines.append(f"## {size_key}\n")
807 lines.append("| Test | Type | Pickle Size (MB) | Time (ms) | Stdev (ms) | Peak Memory (MB) |")
808 lines.append("|------|------|------------------|-----------|------------|------------------|")
809
810 for test_name, data in tests.items():
811 lines.append(
812 f"| {data['test_name']} | "
813 f"{data['object_type']} | "
814 f"{data['pickle_size_mb']:.2f} | "
815 f"{data['time']['mean']*1000:.2f} | "
816 f"{data['time']['stdev']*1000:.2f} | "
817 f"{data['memory_peak_mb']:.2f} |"
818 )
819 lines.append("")
820
821 return "\n".join(lines)
822
823 @staticmethod
824 def format_json(results: Dict[str, Dict[str, Any]]) -> str:

Callers 1

_format_outputFunction · 0.80

Calls 3

appendMethod · 0.45
itemsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected