Skip to content

Commit ccccbcc

Browse files
authored
fix: deal with throughput in bits (#861)
1 parent deb0eb0 commit ccccbcc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

benches/benchmarks/custom_measurement.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ impl ValueFormatter for HalfSecFormatter {
1818
Throughput::Bytes(bytes) | Throughput::BytesDecimal(bytes) => {
1919
format!("{} b/s/2", (bytes as f64) / (value * 2f64 * 10f64.powi(-9)))
2020
}
21+
Throughput::Bits(bits) => {
22+
format!(
23+
"{} bits/s/2",
24+
(bits as f64) / (value * 2f64 * 10f64.powi(-9))
25+
)
26+
}
2127
Throughput::Elements(elems) => format!(
2228
"{} elem/s/2",
2329
(elems as f64) / (value * 2f64 * 10f64.powi(-9))
@@ -47,6 +53,13 @@ impl ValueFormatter for HalfSecFormatter {
4753

4854
"b/s/2"
4955
}
56+
Throughput::Bits(bits) => {
57+
for val in values {
58+
*val = (bits as f64) / (*val * 2f64 * 10f64.powi(-9));
59+
}
60+
61+
"bits/s/2"
62+
}
5063
Throughput::Elements(elems) => {
5164
for val in values {
5265
*val = (elems as f64) / (*val * 2f64 * 10f64.powi(-9));

src/csv_report.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<W: Write> CsvReportWriter<W> {
3838
Some(Throughput::Bytes(bytes)) => (Some(format!("{}", bytes)), Some("bytes")),
3939
Some(Throughput::BytesDecimal(bytes)) => (Some(format!("{}", bytes)), Some("bytes")),
4040
Some(Throughput::Elements(elems)) => (Some(format!("{}", elems)), Some("elements")),
41+
Some(Throughput::Bits(bits)) => (Some(format!("{}", bits)), Some("bits")),
4142
None => (None, None),
4243
};
4344
let throughput_num = throughput_num.as_deref();

0 commit comments

Comments
 (0)