aboutsummaryrefslogtreecommitdiff
path: root/src/crates/cli
diff options
context:
space:
mode:
authorAria Shrimpton <me@aria.rip>2024-01-31 17:32:10 +0000
committerAria Shrimpton <me@aria.rip>2024-01-31 17:32:10 +0000
commiteafe2080e9e825649bd84edba9647df0e811af99 (patch)
tree47307bb0b8ae282578c48741e87c204c440c7082 /src/crates/cli
parent4c96b7fd7a6ec2f6a0d1d0b61c005c0e1b08c2a0 (diff)
add partitioning of collection lifetimes
Diffstat (limited to 'src/crates/cli')
-rw-r--r--src/crates/cli/src/display.rs (renamed from src/crates/cli/src/util.rs)15
-rw-r--r--src/crates/cli/src/estimate.rs2
-rw-r--r--src/crates/cli/src/main.rs2
-rw-r--r--src/crates/cli/src/profile.rs12
4 files changed, 22 insertions, 9 deletions
diff --git a/src/crates/cli/src/util.rs b/src/crates/cli/src/display.rs
index 499f4ba..2ce9039 100644
--- a/src/crates/cli/src/util.rs
+++ b/src/crates/cli/src/display.rs
@@ -1,5 +1,6 @@
use std::{collections::HashSet, fmt::Display, hash::Hash, iter::once};
+use candelabra::profiler::ProfilerInfo;
use tabled::{builder::Builder, settings::Style};
// Print the given 2D map as a table, where the first key is the left-most column, and the second key the column index
@@ -40,3 +41,17 @@ where
println!("{}", builder.build().with(Style::sharp()));
}
+
+pub fn display_profiler_info(profile_info: ProfilerInfo) {
+ print_table(profile_info.0.into_iter().enumerate().map(|(i, p)| {
+ (
+ i,
+ [
+ ("n".to_string(), p.avg_n),
+ ("occurences".to_string(), p.occurences),
+ ]
+ .into_iter()
+ .chain(p.avg_op_counts.into_iter()),
+ )
+ }))
+}
diff --git a/src/crates/cli/src/estimate.rs b/src/crates/cli/src/estimate.rs
index 6915afd..6f4716f 100644
--- a/src/crates/cli/src/estimate.rs
+++ b/src/crates/cli/src/estimate.rs
@@ -4,7 +4,7 @@ use anyhow::{anyhow, bail, Result};
use argh::FromArgs;
use log::info;
-use crate::{util::print_table, State};
+use crate::{display::print_table, State};
/// Estimate the cost of a given set of assignments for a specific project, and detail how that was reached.
#[derive(FromArgs)]
diff --git a/src/crates/cli/src/main.rs b/src/crates/cli/src/main.rs
index 81d484d..04bcc96 100644
--- a/src/crates/cli/src/main.rs
+++ b/src/crates/cli/src/main.rs
@@ -4,12 +4,12 @@ use candelabra::{Paths, Project};
use log::info;
mod candidates;
+mod display;
mod estimate;
mod library;
mod model;
mod profile;
mod select;
-mod util;
#[derive(FromArgs)]
/// Find the best performing container type using primrose
diff --git a/src/crates/cli/src/profile.rs b/src/crates/cli/src/profile.rs
index 0971771..efb1571 100644
--- a/src/crates/cli/src/profile.rs
+++ b/src/crates/cli/src/profile.rs
@@ -2,7 +2,7 @@ use anyhow::Result;
use argh::FromArgs;
use log::info;
-use crate::{util::print_table, State};
+use crate::{display::display_profiler_info, State};
/// Profile the selected projects and print the results
#[derive(FromArgs)]
@@ -16,12 +16,10 @@ impl State {
let all_info = self.inner.profiler_info(proj)?;
- print_table(all_info.iter().map(|(con_type_name, profile_info)| {
- (
- con_type_name,
- profile_info.0.iter().flat_map(|cl| cl.op_counts.iter()),
- )
- }));
+ for (con_type_name, profile_info) in all_info {
+ info!("{}:", con_type_name);
+ display_profiler_info(profile_info);
+ }
}
Ok(())
}