update byte-unit

This commit is contained in:
Tamo
2024-07-08 20:58:27 +02:00
parent 4aa7d386d8
commit 9feba5028d
9 changed files with 253 additions and 30 deletions

View File

@ -13,8 +13,9 @@ serde_json = "1.0.120"
tracing = "0.1.40"
tracing-error = "0.2.0"
tracing-subscriber = "0.3.18"
byte-unit = { version = "4.0.19", default-features = false, features = [
byte-unit = { version = "5.1.4", default-features = false, features = [
"std",
"byte",
"serde",
] }
tokio = { version = "1.38.0", features = ["sync"] }

View File

@ -1,6 +1,8 @@
use std::collections::HashMap;
use std::io::Read;
use byte_unit::UnitType;
use crate::entry::{
Entry, Event, MemoryStats, NewCallsite, NewSpan, NewThread, ResourceId, SpanClose, SpanEnter,
SpanExit, SpanId,
@ -190,6 +192,6 @@ fn print_duration(duration: std::time::Duration) -> String {
/// Format only the allocated bytes, deallocated bytes and reallocated bytes in GiB, MiB, KiB, Bytes.
fn print_memory(MemoryStats { resident }: MemoryStats) -> String {
use byte_unit::Byte;
let rss_bytes = Byte::from_bytes(resident).get_appropriate_unit(true);
let rss_bytes = Byte::from_u64(resident).get_appropriate_unit(UnitType::Binary);
format!("RSS {rss_bytes:.2}")
}