Skip to content

Commit

Permalink
bencher: pretty-print RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
greatest-ape committed Jan 1, 2024
1 parent 3d9a35d commit 98ce4ca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/bencher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ aquatic_udp_load_test = { optional = true, workspace = true }

anyhow = "1"
clap = { version = "4", features = ["derive"] }
humanize-bytes = "1"
indexmap = "2"
indoc = "2"
itertools = "0.12"
Expand Down
6 changes: 4 additions & 2 deletions crates/bencher/src/html.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use humanize_bytes::humanize_bytes_binary;
use indexmap::{IndexMap, IndexSet};
use indoc::formatdoc;
use itertools::Itertools;
Expand Down Expand Up @@ -198,7 +199,7 @@ pub fn html_all_runs(all_results: &[TrackerCoreCountResults]) -> String {
<td>{avg_responses}</td>
{tracker_key_values}
<td>{cpu}%</td>
<td>{mem} kB</td>
<td>{mem}</td>
<td>{tracker_vcpus}</td>
{load_test_key_values}
<td>{load_test_vcpus}</td>
Expand All @@ -212,7 +213,8 @@ pub fn html_all_runs(all_results: &[TrackerCoreCountResults]) -> String {
}).join("\n"),
cpu = r.tracker_stats.map(|stats| stats.avg_cpu_utilization.to_string())
.unwrap_or_else(|| "-".to_string()),
mem = r.tracker_stats.map(|stats| stats.peak_rss_kb.to_string())
mem = r.tracker_stats
.map(|stats| humanize_bytes_binary!(stats.peak_rss_bytes).to_string())
.unwrap_or_else(|| "-".to_string()),
tracker_vcpus = r.tracker_vcpus,
load_test_key_values = load_test_key_names.iter().map(|name| {
Expand Down
9 changes: 6 additions & 3 deletions crates/bencher/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<C> std::fmt::Display for RunErrorResults<C> {
#[derive(Debug, Clone, Copy)]
pub struct ProcessStats {
pub avg_cpu_utilization: f32,
pub peak_rss_kb: f32,
pub peak_rss_bytes: u64,
}

impl FromStr for ProcessStats {
Expand All @@ -324,9 +324,12 @@ impl FromStr for ProcessStats {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut parts = s.trim().split_whitespace();

let avg_cpu_utilization = parts.next().ok_or(())?.parse().map_err(|_| ())?;
let peak_rss_kb: f32 = parts.next().ok_or(())?.parse().map_err(|_| ())?;

Ok(Self {
avg_cpu_utilization: parts.next().ok_or(())?.parse().map_err(|_| ())?,
peak_rss_kb: parts.next().ok_or(())?.parse().map_err(|_| ())?,
avg_cpu_utilization,
peak_rss_bytes: (peak_rss_kb * 1000.0) as u64,
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/bencher/src/set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::rc::Rc;

use humanize_bytes::humanize_bytes_binary;
use indexmap::IndexMap;
use num_format::{Locale, ToFormattedString};

Expand Down Expand Up @@ -207,8 +208,8 @@ impl LoadTestRunResults {
r.tracker_process_stats.avg_cpu_utilization,
);
println!(
"- Peak tracker RSS: {} kB",
r.tracker_process_stats.peak_rss_kb
"- Peak tracker RSS: {}",
humanize_bytes_binary!(r.tracker_process_stats.peak_rss_bytes)
);

LoadTestRunResults::Success(LoadTestRunResultsSuccess {
Expand Down

0 comments on commit 98ce4ca

Please sign in to comment.