Format bytes in human-readable format.
(size_bytes: int)
| 42 | |
| 43 | |
| 44 | def format_size(size_bytes: int) -> str: |
| 45 | """Format bytes in human-readable format.""" |
| 46 | if size_bytes < 1024: |
| 47 | return f"{size_bytes}B" |
| 48 | elif size_bytes < 1024 * 1024: |
| 49 | return f"{size_bytes / 1024:.2f}KB" |
| 50 | else: |
| 51 | return f"{size_bytes / (1024 * 1024):.2f}MB" |
| 52 | |
| 53 | |
| 54 | def benchmark_memory(name: str, data: dict): |
no outgoing calls
no test coverage detected
searching dependent graphs…