MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / format_bytes

Method format_bytes

graphlite/src/exec/memory_budget.rs:265–279  ·  view source on GitHub ↗

ROADMAP v0.5.0 - Byte formatting utility for memory statistics

(bytes: usize)

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected