Skip to content

Commit

Permalink
clean-up output, fix alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
code-inflation committed Feb 24, 2023
1 parent 8a5574a commit e713757
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [ ] Dynamic payload sizing depending on network speed
- [ ] Consider server processing time in measurements
- [X] CLI arguments (~~nr of tests~~, ~~payload sizes~~, ~~verbosity~~)
- [ ] Clean up outputs
- [X] Clean up output
- [X] Boxplot for measurements
- [ ] Asciinema recording in readme
- [ ] Publish crate
Expand Down
8 changes: 6 additions & 2 deletions src/measurements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pub(crate) fn log_measurements(
payload_sizes: Vec<usize>,
verbose: bool,
) {
println!("\n### STATS ###");
println!("\nSummary Statistics");
println!("Type Payload | min/max/avg in mbit/s");
measurements
.iter()
.map(|m| m.test_type)
Expand All @@ -52,7 +53,10 @@ fn log_measurements_by_test_type(
let (min, q1, median, q3, max, avg) = calc_stats(type_measurements).unwrap();

let formated_payload = format_bytes(payload_size);
println!("{test_type:?} {formated_payload}: min {min:.2}, max {max:.2}, avg {avg:.2}");
let fmt_test_type = format!("{:?}", test_type);
println!(
"{fmt_test_type:<9} {formated_payload:<7}| min {min:<7.2} max {max:<7.2} avg {avg:<7.2}"
);
if verbose {
let plot = boxplot::render_plot(min, q1, median, q3, max);
println!("{plot}\n");
Expand Down
2 changes: 1 addition & 1 deletion src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn print_progress(name: &str, curr: u32, max: u32) {
let progress_line = ((curr as f32 / max as f32) * BAR_LEN as f32) as u32;
let remaining_line = BAR_LEN - progress_line;
print!(
"\r{} [{}{}]",
"\r{:<15} [{}{}]",
name,
(0..progress_line).map(|_| "=").collect::<String>(),
(0..remaining_line).map(|_| "-").collect::<String>(),
Expand Down
2 changes: 1 addition & 1 deletion src/speedtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn print_current_speed(
payload_size_bytes: usize,
) {
print!(
"\t {:.2} mbit/s | {} in {}ms -> status: {} ",
" {:>6.2} mbit/s | {:>5} in {:>4}ms -> status: {} ",
mbits,
format_bytes(payload_size_bytes),
duration.as_millis(),
Expand Down

0 comments on commit e713757

Please sign in to comment.