Skip to content

Commit e69b45a

Browse files
committed
feat(bench): restore newline spacing and add --quiet flag
Changes: 1. Restored newline before each benchmark in normal mode for readability 2. Removed extra blank line after 'Output format:' line 3. Added --quiet (-q) flag for minimal output Normal mode output: - Newline before each 'Benchmarking' line for visual separation - Shows full benchmark results and summary tables Quiet mode output (--quiet): - No newlines between benchmarks - Only shows 'Benchmarking X ... ✓' progress lines - Hides header, results tables, and summary - Perfect for CI/monitoring where you only need status Example: bench_throughput --sizes 100 --iterations 5 # Normal bench_throughput --sizes 100 --iterations 5 --quiet # Minimal
1 parent d6469e2 commit e69b45a

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

src/bin/bench_throughput.rs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,13 @@ fn main() {
777777
.value_name("FILE")
778778
.help("Output file path (for JSON format)"),
779779
)
780+
.arg(
781+
Arg::new("quiet")
782+
.short('q')
783+
.long("quiet")
784+
.action(clap::ArgAction::SetTrue)
785+
.help("Minimal output (only show benchmark progress lines)"),
786+
)
780787
.get_matches();
781788

782789
// Parse arguments
@@ -799,37 +806,45 @@ fn main() {
799806
let detailed = matches.get_flag("detailed");
800807
let format = matches.get_one::<String>("format").unwrap();
801808
let output_path = matches.get_one::<String>("output");
809+
let quiet = matches.get_flag("quiet");
802810

803811
if sizes.is_empty() {
804812
eprintln!("Error: At least one input size is required");
805813
std::process::exit(1);
806814
}
807815

808-
println!("String Pipeline Throughput Benchmark");
809-
println!("=====================================");
810-
println!("Measuring batch processing performance with varying input sizes");
811-
println!("Pattern: Parse once, format N paths individually");
812-
println!();
813-
println!(
814-
"Input sizes: {:?}",
815-
sizes.iter().map(|s| format_size(*s)).collect::<Vec<_>>()
816-
);
817-
println!("Measurement iterations: {}", iterations);
818-
println!("Detailed profiling: {}", if detailed { "enabled" } else { "disabled" });
819-
println!("Output format: {}", format);
820-
println!();
816+
if !quiet {
817+
println!("String Pipeline Throughput Benchmark");
818+
println!("=====================================");
819+
println!("Measuring batch processing performance with varying input sizes");
820+
println!("Pattern: Parse once, format N paths individually");
821+
println!();
822+
println!(
823+
"Input sizes: {:?}",
824+
sizes.iter().map(|s| format_size(*s)).collect::<Vec<_>>()
825+
);
826+
println!("Measurement iterations: {}", iterations);
827+
println!("Detailed profiling: {}", if detailed { "enabled" } else { "disabled" });
828+
println!("Output format: {}", format);
829+
}
821830

822831
let templates = TemplateSet::get_templates();
823832
let mut all_results = Vec::new();
824833

825834
for (template_name, template_str) in &templates {
826-
print!("Benchmarking '{}' ... ", template_name);
835+
if quiet {
836+
print!("Benchmarking '{}' ... ", template_name);
837+
} else {
838+
print!("\nBenchmarking '{}' ... ", template_name);
839+
}
827840
std::io::Write::flush(&mut std::io::stdout()).unwrap();
828841

829842
match benchmark_template(template_name, template_str, &sizes, iterations, detailed) {
830843
Ok(results) => {
831844
println!("✓");
832-
print_template_results(template_name, &results, detailed);
845+
if !quiet {
846+
print_template_results(template_name, &results, detailed);
847+
}
833848
all_results.push((*template_name, results));
834849
}
835850
Err(e) => {
@@ -839,7 +854,9 @@ fn main() {
839854
}
840855
}
841856

842-
print_summary(&all_results);
857+
if !quiet {
858+
print_summary(&all_results);
859+
}
843860

844861
if format == "json" {
845862
if let Err(e) = output_json(&all_results, output_path.map(|s| s.as_str())) {
@@ -848,6 +865,8 @@ fn main() {
848865
}
849866
}
850867

851-
println!("\n{}", "=".repeat(110));
852-
println!("Benchmark complete!");
868+
if !quiet {
869+
println!("\n{}", "=".repeat(110));
870+
println!("Benchmark complete!");
871+
}
853872
}

0 commit comments

Comments
 (0)