MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / human_bytes

Function human_bytes

src/upload/uploader.rs:29–43  ·  view source on GitHub ↗
(bytes: u64)

Source from the content-addressed store, hash-verified

27use super::s3;
28
29fn human_bytes(bytes: u64) -> String {
30 const KB: u64 = 1024;
31 const MB: u64 = KB * 1024;
32 const GB: u64 = MB * 1024;
33
34 if bytes >= GB {
35 format!("{:.2} GB", bytes as f64 / GB as f64)
36 } else if bytes >= MB {
37 format!("{:.2} MB", bytes as f64 / MB as f64)
38 } else if bytes >= KB {
39 format!("{:.2} KB", bytes as f64 / KB as f64)
40 } else {
41 format!("{bytes}")
42 }
43}
44
45fn human_bytes_per_second(bytes: u64, elapsed: std::time::Duration) -> String {
46 let bytes_per_second = bytes as f64 / elapsed.as_secs_f64();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected