validate-shaping: show approx memory usage of processed files

This commit is contained in:
Wez Furlong
2024-12-10 11:16:16 -07:00
parent db7d846e3a
commit fa276973c4
3 changed files with 14 additions and 0 deletions
Generated
+2
View File
@@ -7373,7 +7373,9 @@ version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"human_bytes",
"kumo-api-types",
"re_memory",
"tokio",
]
+2
View File
@@ -6,5 +6,7 @@ edition = "2021"
[dependencies]
anyhow = {workspace=true}
clap = {workspace=true}
human_bytes.workspace = true
kumo-api-types = {path="../kumo-api-types", features=["lua"]}
re_memory.workspace = true
tokio = {workspace=true, features=["full"]}
+10
View File
@@ -1,5 +1,7 @@
use clap::Parser;
use human_bytes::human_bytes;
use kumo_api_types::shaping::{CheckLevel, Shaping, ShapingMergeOptions};
use re_memory::MemoryUse;
/// KumoMTA shaping configuration validator
///
@@ -82,8 +84,11 @@ async fn main() {
local_load: opts.local_load,
};
let memory_start = MemoryUse::capture();
match Shaping::merge_files(&opts.files, &shaping_opts).await {
Ok(merged) => {
let memory_end = MemoryUse::capture();
for err in merged.get_errors() {
eprintln!("ERROR: {err}");
failed = true;
@@ -91,6 +96,11 @@ async fn main() {
for warn in merged.get_warnings() {
eprintln!("WARNING: {warn}");
}
let counted = memory_end
.counted
.unwrap_or(0)
.saturating_sub(memory_start.counted.unwrap_or(0));
println!("INFO: approx memory used = {}", human_bytes(counted as f64));
if !failed {
eprintln!("OK");
}