Skip to content

Commit 1435ca2

Browse files
authored
fix: Rename throughput fields from mbps to mb_s for correctness (#113)
* fix: Rename throughput fields from mbps to mb_s for correctness The throughput fields were named average_throughput_mbps and peak_throughput_mbps, which conventionally means "megabits per second." However, the calculation divides bytes_per_second by 1,000,000, producing megabytes per second (MB/s). This rename corrects the field names to match the actual unit. Changes: - Rename average_throughput_mbps → average_throughput_mb_s - Rename peak_throughput_mbps → peak_throughput_mb_s - Update doc comments from "megabits" to "megabytes per second (MB/s)" - Remove workaround comments that acknowledged the mismatch - Update JSON example in README.md - All tests passing, clippy clean Fixes: #112 BREAKING CHANGE: Serialized JSON field names changed from *_mbps to *_mb_s. Downstream consumers must update accordingly. AI-assisted-by: Claude Opus 4 (Cursor agent) Made-with: Cursor * fix: Use fully verbose throughput field names per review Rename average_throughput_mb_s → average_throughput_megabytes_per_sec and peak_throughput_mb_s → peak_throughput_megabytes_per_sec for unambiguous field naming in serialized output. AI-assisted-by: Claude Opus 4 (Cursor agent) Made-with: Cursor
1 parent 2bbcd52 commit 1435ca2

3 files changed

Lines changed: 35 additions & 29 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ The benchmark generates comprehensive JSON output with the following structure:
658658
"summary": {
659659
"total_messages_sent": 10000,
660660
"total_bytes_transferred": 10240000,
661-
"average_throughput_mbps": 305.17,
661+
"average_throughput_megabytes_per_sec": 305.17,
662662
"p95_latency_ns": 5200,
663663
"p99_latency_ns": 8500
664664
}

src/results.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ pub struct BenchmarkSummary {
368368
/// Total number of bytes transferred during all tests
369369
pub total_bytes_transferred: usize,
370370

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

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

377377
/// Average latency across all latency measurements (if any)
378378
pub average_latency_ns: Option<f64>,
@@ -1133,7 +1133,9 @@ impl ResultsManager {
11331133
result.mechanism.to_string(),
11341134
MechanismSummary {
11351135
mechanism: result.mechanism,
1136-
average_throughput_mbps: result.summary.average_throughput_mbps,
1136+
average_throughput_megabytes_per_sec: result
1137+
.summary
1138+
.average_throughput_megabytes_per_sec,
11371139
p95_latency_ns: result.summary.p95_latency_ns,
11381140
p99_latency_ns: result.summary.p99_latency_ns,
11391141
total_messages: result.summary.total_messages_sent,
@@ -1163,16 +1165,16 @@ impl ResultsManager {
11631165
///
11641166
/// ## Comparison Method
11651167
///
1166-
/// Comparison is based on average throughput in megabits per second,
1168+
/// Comparison is based on average throughput in megabytes per second,
11671169
/// which provides a consistent measure across different message sizes
11681170
/// and test configurations.
11691171
fn find_fastest_mechanism(&self) -> Option<String> {
11701172
self.results
11711173
.iter()
11721174
.max_by(|a, b| {
11731175
a.summary
1174-
.average_throughput_mbps
1175-
.partial_cmp(&b.summary.average_throughput_mbps)
1176+
.average_throughput_megabytes_per_sec
1177+
.partial_cmp(&b.summary.average_throughput_megabytes_per_sec)
11761178
.unwrap()
11771179
})
11781180
.map(|result| result.mechanism.to_string())
@@ -1380,11 +1382,12 @@ impl ResultsManager {
13801382
let summary = &result.summary;
13811383

13821384
println!("{}Throughput:", indent);
1383-
// Note: The summary field is named _mbps, but the calculation in update_summary
1384-
// produces MB/s (Megabytes per second). The label reflects the calculation.
13851385
println!(
13861386
"{}{:<8} Average: {:.2} MB/s, Peak: {:.2} MB/s",
1387-
indent, " ", summary.average_throughput_mbps, summary.peak_throughput_mbps
1387+
indent,
1388+
" ",
1389+
summary.average_throughput_megabytes_per_sec,
1390+
summary.peak_throughput_megabytes_per_sec
13881391
);
13891392

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

1528-
/// Average throughput performance in megabits per second
1529-
pub average_throughput_mbps: f64,
1531+
/// Average throughput performance in megabytes per second (MB/s)
1532+
pub average_throughput_megabytes_per_sec: f64,
15301533

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

16931696
// Calculate summary metrics
1694-
let average_throughput_mbps =
1697+
let average_throughput_megabytes_per_sec =
16951698
throughput_values.iter().sum::<f64>() / throughput_values.len() as f64 / 1_000_000.0;
1696-
let peak_throughput_mbps =
1699+
let peak_throughput_megabytes_per_sec =
16971700
throughput_values.iter().cloned().fold(0.0, f64::max) / 1_000_000.0;
16981701

16991702
// Calculate properly weighted average latency across all test types
@@ -1705,8 +1708,8 @@ impl BenchmarkResults {
17051708
self.summary = BenchmarkSummary {
17061709
total_messages_sent: total_messages,
17071710
total_bytes_transferred: total_bytes,
1708-
average_throughput_mbps,
1709-
peak_throughput_mbps,
1711+
average_throughput_megabytes_per_sec,
1712+
peak_throughput_megabytes_per_sec,
17101713
average_latency_ns,
17111714
min_latency_ns,
17121715
max_latency_ns,
@@ -1851,8 +1854,8 @@ impl Default for BenchmarkSummary {
18511854
Self {
18521855
total_messages_sent: 0,
18531856
total_bytes_transferred: 0,
1854-
average_throughput_mbps: 0.0,
1855-
peak_throughput_mbps: 0.0,
1857+
average_throughput_megabytes_per_sec: 0.0,
1858+
peak_throughput_megabytes_per_sec: 0.0,
18561859
average_latency_ns: None,
18571860
min_latency_ns: None,
18581861
max_latency_ns: None,

src/results_blocking.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,9 @@ impl BlockingResultsManager {
10051005
result.mechanism.to_string(),
10061006
MechanismSummary {
10071007
mechanism: result.mechanism,
1008-
average_throughput_mbps: result.summary.average_throughput_mbps,
1008+
average_throughput_megabytes_per_sec: result
1009+
.summary
1010+
.average_throughput_megabytes_per_sec,
10091011
p95_latency_ns: result.summary.p95_latency_ns,
10101012
p99_latency_ns: result.summary.p99_latency_ns,
10111013
total_messages: result.summary.total_messages_sent,
@@ -1035,16 +1037,16 @@ impl BlockingResultsManager {
10351037
///
10361038
/// ## Comparison Method
10371039
///
1038-
/// Comparison is based on average throughput in megabits per second,
1040+
/// Comparison is based on average throughput in megabytes per second,
10391041
/// which provides a consistent measure across different message sizes
10401042
/// and test configurations.
10411043
fn find_fastest_mechanism(&self) -> Option<String> {
10421044
self.results
10431045
.iter()
10441046
.max_by(|a, b| {
10451047
a.summary
1046-
.average_throughput_mbps
1047-
.partial_cmp(&b.summary.average_throughput_mbps)
1048+
.average_throughput_megabytes_per_sec
1049+
.partial_cmp(&b.summary.average_throughput_megabytes_per_sec)
10481050
.unwrap()
10491051
})
10501052
.map(|result| result.mechanism.to_string())
@@ -1261,11 +1263,12 @@ impl BlockingResultsManager {
12611263
let summary = &result.summary;
12621264

12631265
println!("{}Throughput:", indent);
1264-
// Note: The summary field is named _mbps, but the calculation in update_summary
1265-
// produces MB/s (Megabytes per second). The label reflects the calculation.
12661266
println!(
12671267
"{}{:<8} Average: {:.2} MB/s, Peak: {:.2} MB/s",
1268-
indent, " ", summary.average_throughput_mbps, summary.peak_throughput_mbps
1268+
indent,
1269+
" ",
1270+
summary.average_throughput_megabytes_per_sec,
1271+
summary.peak_throughput_megabytes_per_sec
12691272
);
12701273

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

21922195
// Add results with different throughputs
21932196
let mut results1 = create_test_results();
2194-
results1.summary.average_throughput_mbps = 100.0;
2197+
results1.summary.average_throughput_megabytes_per_sec = 100.0;
21952198
manager.add_results(results1).unwrap();
21962199

21972200
// Create a second result with higher throughput
@@ -2206,7 +2209,7 @@ mod tests {
22062209
true,
22072210
true,
22082211
);
2209-
results2.summary.average_throughput_mbps = 200.0; // Higher
2212+
results2.summary.average_throughput_megabytes_per_sec = 200.0; // Higher
22102213
manager.add_results(results2).unwrap();
22112214

22122215
// The fastest should be SharedMemory

0 commit comments

Comments
 (0)