summaryrefslogtreecommitdiff
path: root/src/report.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-16 10:02:03 +0000
committerLars Wirzenius <liw@liw.fi>2022-01-16 10:02:03 +0000
commit93584ec7e8b774c19d6b9c2ebc64a4513a961d96 (patch)
tree7ff13c1cd7e04b47a6aa20c22953605bcb05d34e /src/report.rs
parent1ad4e5d867cf9b040de48371cce55bdb3ad001ea (diff)
parent8c799a2161d57f1b0f965ade59a8b7e690660cbe (diff)
downloadobnam-benchmark-93584ec7e8b774c19d6b9c2ebc64a4513a961d96.tar.gz
Merge branch 'fix-version-column' into 'main'
feat: allow report to write to named file See merge request obnam/obnam-benchmark!13
Diffstat (limited to 'src/report.rs')
-rw-r--r--src/report.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/report.rs b/src/report.rs
index 0538760..297195d 100644
--- a/src/report.rs
+++ b/src/report.rs
@@ -3,6 +3,8 @@ use std::collections::HashSet;
use std::io::Write;
use std::iter::FromIterator;
+const COMMIT_DIGITS: usize = 7;
+
#[derive(Debug, Default)]
pub struct Reporter {
results: Vec<SuiteMeasurements>,
@@ -109,6 +111,7 @@ impl Reporter {
.enumerate()
.map(|(i, _)| format!("step {}", i))
.collect();
+ headings.insert(0, "Commit".to_string());
headings.insert(0, "Version".to_string());
for h in headings.iter() {
write!(f, "| {}", h)?;
@@ -129,7 +132,8 @@ impl Reporter {
r: &SuiteMeasurements,
durations: &[u128],
) -> Result<(), std::io::Error> {
- write!(f, "| {}", r.obnam_version())?;
+ write!(f, "| {}", pretty_version(r.obnam_version()))?;
+ write!(f, "| {}", pretty_commit(r.obnam_commit()))?;
for ms in durations.iter() {
write!(f, "| {}", ms)?;
}
@@ -162,3 +166,19 @@ impl Reporter {
.filter(move |r| r.hostname() == hostname)
}
}
+
+fn pretty_version(v: &str) -> String {
+ if let Some(v) = v.strip_prefix("obnam-backup ") {
+ v.to_string()
+ } else {
+ v.to_string()
+ }
+}
+
+fn pretty_commit(c: Option<&str>) -> String {
+ if let Some(c) = c {
+ c[..COMMIT_DIGITS].to_string()
+ } else {
+ "".to_string()
+ }
+}