ROADMAP v0.5.0 - Byte formatting utility for memory statistics
(bytes: usize)
| 263 | /// Format bytes as human-readable (KB, MB, GB) |
| 264 | #[allow(dead_code)] // ROADMAP v0.5.0 - Byte formatting utility for memory statistics |
| 265 | fn format_bytes(bytes: usize) -> String { |
| 266 | const KB: usize = 1024; |
| 267 | const MB: usize = KB * 1024; |
| 268 | const GB: usize = MB * 1024; |
| 269 | |
| 270 | if bytes >= GB { |
| 271 | format!("{:.2}GB", bytes as f64 / GB as f64) |
| 272 | } else if bytes >= MB { |
| 273 | format!("{:.2}MB", bytes as f64 / MB as f64) |
| 274 | } else if bytes >= KB { |
| 275 | format!("{:.2}KB", bytes as f64 / KB as f64) |
| 276 | } else { |
| 277 | format!("{}B", bytes) |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | #[cfg(test)] |
nothing calls this directly
no outgoing calls
no test coverage detected