summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-01-10 09:04:34 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-01-10 09:04:34 -0500
commitfc73d9293579ff76800259090b6c5e545604827a (patch)
tree6d362cbc49a3fcec62e190aa48da0ce69de0bc9c
parentb946538b34675913f6685b9fa42968d1eb6c55e1 (diff)
Output includes percentages
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--src/main.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 3347aef..9354c88 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,6 +14,11 @@ use toml;
const RESULTS: &str = "perf-results.toml";
type DataPoints = HashMap<String, f32>;
+type DataPointsDeltas = HashMap<String, (f32, f32)>;
+
+fn dps_to_dpdeltas(d: &DataPoints) -> DataPointsDeltas {
+ d.iter().map(|x| (x.0.clone(), (*x.1, 0.0)) ).collect()
+}
struct TestResult {
commit: String,
@@ -23,6 +28,14 @@ struct TestResult {
type TestResultsVec = Vec<TestResult>;
+struct TestResultDeltas {
+ commit: String,
+ commitmsg: String,
+ data_points: DataPointsDeltas,
+}
+
+type TestResultsDeltasVec = Vec<TestResultDeltas>;
+
#[derive(Serialize, Deserialize)]
struct TestResultsMap {
d: HashMap<String, DataPoints>,
@@ -231,6 +244,28 @@ fn log_with_results(repo: &git2::Repository,
Ok(v)
}
+fn results_to_results_with_deltas(results: TestResultsVec) -> TestResultsDeltasVec {
+ let mut results: TestResultsDeltasVec = results.iter().map(|i| TestResultDeltas {
+ commit: i.commit.clone(),
+ commitmsg: i.commitmsg.clone(),
+ data_points: dps_to_dpdeltas(&i.data_points)
+ }).collect();
+
+ let mut last: DataPoints = HashMap::new();
+
+ for i in results.iter_mut().rev() {
+ for c in i.data_points.iter_mut() {
+ if let Some(l) = last.get(c.0) {
+ c.1.1 = (c.1.0 - l) / l;
+ }
+
+ last.insert(c.0.clone(), c.1.0);
+ }
+ };
+
+ results
+}
+
fn list_tests(repo: &git2::Repository, head: &Option<String>) {
colored::control::set_override(true);
Pager::with_pager("less -FRX").setup();
@@ -238,6 +273,8 @@ fn list_tests(repo: &git2::Repository, head: &Option<String>) {
let results = results_read(RESULTS).unwrap();
let log = log_with_results(repo, head, &results).unwrap();
+ let log = results_to_results_with_deltas(log);
+
let mut columns = HashSet::new();
for r in log.iter() {
for e in r.data_points.iter() {
@@ -256,7 +293,14 @@ fn list_tests(repo: &git2::Repository, head: &Option<String>) {
for e in columns.iter() {
if let Some(v) = i.data_points.get(e.clone()) {
- print!("{:20}", v);
+ let f = format!("{:12} {:+6.1}%", v.0, v.1 * 100.0);
+ let f = if v.1 < 0.0 {
+ f.red()
+ } else {
+ f.normal()
+ };
+
+ print!("{}", f);
} else {
print!("{:20}", "");
}