Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ The benchmark generates comprehensive JSON output with the following structure:
"summary": {
"total_messages_sent": 10000,
"total_bytes_transferred": 10240000,
"average_throughput_mbps": 305.17,
"average_throughput_megabytes_per_sec": 305.17,
"p95_latency_ns": 5200,
"p99_latency_ns": 8500
}
Expand Down
41 changes: 22 additions & 19 deletions src/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,11 @@ pub struct BenchmarkSummary {
/// Total number of bytes transferred during all tests
pub total_bytes_transferred: usize,

/// Average throughput across all tests in megabits per second
pub average_throughput_mbps: f64,
/// Average throughput across all tests in megabytes per second (MB/s)
pub average_throughput_megabytes_per_sec: f64,

/// Peak throughput observed in any single test in megabits per second
pub peak_throughput_mbps: f64,
/// Peak throughput observed in any single test in megabytes per second (MB/s)
pub peak_throughput_megabytes_per_sec: f64,

/// Average latency across all latency measurements (if any)
pub average_latency_ns: Option<f64>,
Expand Down Expand Up @@ -1133,7 +1133,9 @@ impl ResultsManager {
result.mechanism.to_string(),
MechanismSummary {
mechanism: result.mechanism,
average_throughput_mbps: result.summary.average_throughput_mbps,
average_throughput_megabytes_per_sec: result
.summary
.average_throughput_megabytes_per_sec,
p95_latency_ns: result.summary.p95_latency_ns,
p99_latency_ns: result.summary.p99_latency_ns,
total_messages: result.summary.total_messages_sent,
Expand Down Expand Up @@ -1163,16 +1165,16 @@ impl ResultsManager {
///
/// ## Comparison Method
///
/// Comparison is based on average throughput in megabits per second,
/// Comparison is based on average throughput in megabytes per second,
/// which provides a consistent measure across different message sizes
/// and test configurations.
fn find_fastest_mechanism(&self) -> Option<String> {
self.results
.iter()
.max_by(|a, b| {
a.summary
.average_throughput_mbps
.partial_cmp(&b.summary.average_throughput_mbps)
.average_throughput_megabytes_per_sec
.partial_cmp(&b.summary.average_throughput_megabytes_per_sec)
.unwrap()
})
.map(|result| result.mechanism.to_string())
Expand Down Expand Up @@ -1380,11 +1382,12 @@ impl ResultsManager {
let summary = &result.summary;

println!("{}Throughput:", indent);
// Note: The summary field is named _mbps, but the calculation in update_summary
// produces MB/s (Megabytes per second). The label reflects the calculation.
println!(
"{}{:<8} Average: {:.2} MB/s, Peak: {:.2} MB/s",
indent, " ", summary.average_throughput_mbps, summary.peak_throughput_mbps
indent,
" ",
summary.average_throughput_megabytes_per_sec,
summary.peak_throughput_megabytes_per_sec
);

println!("{}Totals:", indent);
Expand Down Expand Up @@ -1525,8 +1528,8 @@ pub struct MechanismSummary {
/// The IPC mechanism this summary describes
pub mechanism: IpcMechanism,

/// Average throughput performance in megabits per second
pub average_throughput_mbps: f64,
/// Average throughput performance in megabytes per second (MB/s)
pub average_throughput_megabytes_per_sec: f64,

/// 95th percentile latency (if latency was measured)
pub p95_latency_ns: Option<u64>,
Expand Down Expand Up @@ -1691,9 +1694,9 @@ impl BenchmarkResults {
}

// Calculate summary metrics
let average_throughput_mbps =
let average_throughput_megabytes_per_sec =
throughput_values.iter().sum::<f64>() / throughput_values.len() as f64 / 1_000_000.0;
let peak_throughput_mbps =
let peak_throughput_megabytes_per_sec =
throughput_values.iter().cloned().fold(0.0, f64::max) / 1_000_000.0;

// Calculate properly weighted average latency across all test types
Expand All @@ -1705,8 +1708,8 @@ impl BenchmarkResults {
self.summary = BenchmarkSummary {
total_messages_sent: total_messages,
total_bytes_transferred: total_bytes,
average_throughput_mbps,
peak_throughput_mbps,
average_throughput_megabytes_per_sec,
peak_throughput_megabytes_per_sec,
average_latency_ns,
min_latency_ns,
max_latency_ns,
Expand Down Expand Up @@ -1851,8 +1854,8 @@ impl Default for BenchmarkSummary {
Self {
total_messages_sent: 0,
total_bytes_transferred: 0,
average_throughput_mbps: 0.0,
peak_throughput_mbps: 0.0,
average_throughput_megabytes_per_sec: 0.0,
peak_throughput_megabytes_per_sec: 0.0,
average_latency_ns: None,
min_latency_ns: None,
max_latency_ns: None,
Expand Down
21 changes: 12 additions & 9 deletions src/results_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,9 @@ impl BlockingResultsManager {
result.mechanism.to_string(),
MechanismSummary {
mechanism: result.mechanism,
average_throughput_mbps: result.summary.average_throughput_mbps,
average_throughput_megabytes_per_sec: result
.summary
.average_throughput_megabytes_per_sec,
p95_latency_ns: result.summary.p95_latency_ns,
p99_latency_ns: result.summary.p99_latency_ns,
total_messages: result.summary.total_messages_sent,
Expand Down Expand Up @@ -1035,16 +1037,16 @@ impl BlockingResultsManager {
///
/// ## Comparison Method
///
/// Comparison is based on average throughput in megabits per second,
/// Comparison is based on average throughput in megabytes per second,
/// which provides a consistent measure across different message sizes
/// and test configurations.
fn find_fastest_mechanism(&self) -> Option<String> {
self.results
.iter()
.max_by(|a, b| {
a.summary
.average_throughput_mbps
.partial_cmp(&b.summary.average_throughput_mbps)
.average_throughput_megabytes_per_sec
.partial_cmp(&b.summary.average_throughput_megabytes_per_sec)
.unwrap()
})
.map(|result| result.mechanism.to_string())
Expand Down Expand Up @@ -1261,11 +1263,12 @@ impl BlockingResultsManager {
let summary = &result.summary;

println!("{}Throughput:", indent);
// Note: The summary field is named _mbps, but the calculation in update_summary
// produces MB/s (Megabytes per second). The label reflects the calculation.
println!(
"{}{:<8} Average: {:.2} MB/s, Peak: {:.2} MB/s",
indent, " ", summary.average_throughput_mbps, summary.peak_throughput_mbps
indent,
" ",
summary.average_throughput_megabytes_per_sec,
summary.peak_throughput_megabytes_per_sec
);

println!("{}Totals:", indent);
Expand Down Expand Up @@ -2191,7 +2194,7 @@ mod tests {

// Add results with different throughputs
let mut results1 = create_test_results();
results1.summary.average_throughput_mbps = 100.0;
results1.summary.average_throughput_megabytes_per_sec = 100.0;
manager.add_results(results1).unwrap();

// Create a second result with higher throughput
Expand All @@ -2206,7 +2209,7 @@ mod tests {
true,
true,
);
results2.summary.average_throughput_mbps = 200.0; // Higher
results2.summary.average_throughput_megabytes_per_sec = 200.0; // Higher
manager.add_results(results2).unwrap();

// The fastest should be SharedMemory
Expand Down
Loading