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

Method format_text

Tools/picklebench/memory_dos_impact.py:775–797  ·  view source on GitHub ↗

Format results as readable text.

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

Source from the content-addressed store, hash-verified

773
774 @staticmethod
775 def format_text(results: Dict[str, Dict[str, Any]]) -> str:
776 """Format results as readable text."""
777 lines = []
778 lines.append("=" * 80)
779 lines.append("Pickle Unpickling Benchmark Results")
780 lines.append("=" * 80)
781 lines.append("")
782
783 for size_key, tests in results.items():
784 lines.append(f"\n{size_key} Test Results")
785 lines.append("-" * 80)
786
787 for test_name, data in tests.items():
788 lines.append(f"\n Test: {data['test_name']}")
789 lines.append(f" Type: {data['object_type']}")
790 lines.append(f" Pickle size: {data['pickle_size_mb']:.2f} MB")
791 lines.append(f" Time (mean): {data['time']['mean']*1000:.2f} ms")
792 lines.append(f" Time (stdev): {data['time']['stdev']*1000:.2f} ms")
793 lines.append(f" Peak memory: {data['memory_peak_mb']:.2f} MB")
794 lines.append(f" Protocol: {data['protocol']}")
795
796 lines.append("\n" + "=" * 80)
797 return "\n".join(lines)
798
799 @staticmethod
800 def format_markdown(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