mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-19 13:02:27 +00:00
validate-shaping: show approx memory usage of processed files
This commit is contained in:
Generated
+2
@@ -7373,7 +7373,9 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"human_bytes",
|
||||
"kumo-api-types",
|
||||
"re_memory",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
||||
@@ -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"]}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user