aboutsummaryrefslogtreecommitdiff
path: root/src/crates
diff options
context:
space:
mode:
Diffstat (limited to 'src/crates')
-rw-r--r--src/crates/cli/src/cmd.rs39
-rw-r--r--src/crates/cli/src/main.rs55
2 files changed, 59 insertions, 35 deletions
diff --git a/src/crates/cli/src/cmd.rs b/src/crates/cli/src/cmd.rs
new file mode 100644
index 0000000..7f9857d
--- /dev/null
+++ b/src/crates/cli/src/cmd.rs
@@ -0,0 +1,39 @@
+use argh::FromArgs;
+
+#[derive(FromArgs)]
+/// Find the best performing container type using primrose
+pub struct Args {
+ /// path to Cargo.toml
+ #[argh(option)]
+ pub manifest_path: Option<String>,
+
+ /// project to run on, if in a workspace
+ #[argh(option, short = 'p')]
+ pub project: Option<String>,
+
+ #[argh(subcommand)]
+ pub cmd: Subcommand,
+}
+
+#[derive(FromArgs)]
+#[argh(subcommand)]
+pub enum Subcommand {
+ Model(ModelSubcommand),
+ Candidates(CandidatesSubcommand),
+ Profile(ProfileSubcommand),
+}
+
+#[derive(FromArgs)]
+/// Show the cost model for the given implementation
+#[argh(subcommand, name = "cost-model")]
+pub struct ModelSubcommand {}
+
+#[derive(FromArgs)]
+/// Show the candidate types selected by primrose
+#[argh(subcommand, name = "candidates")]
+pub struct CandidatesSubcommand {}
+
+#[derive(FromArgs)]
+/// Show the profiling information generated from benchmarks
+#[argh(subcommand, name = "profile")]
+pub struct ProfileSubcommand {}
diff --git a/src/crates/cli/src/main.rs b/src/crates/cli/src/main.rs
index a9acd16..92941b2 100644
--- a/src/crates/cli/src/main.rs
+++ b/src/crates/cli/src/main.rs
@@ -1,32 +1,22 @@
-use std::collections::HashSet;
-
use anyhow::{anyhow, Context, Result};
-use argh::FromArgs;
+use cmd::{CandidatesSubcommand, ModelSubcommand, ProfileSubcommand};
use log::info;
use project::Project;
-use crate::{candidates::CandidatesStore, cost::ResultsStore, paths::Paths};
+use crate::{
+ cmd::{Args, Subcommand},
+ paths::Paths,
+};
extern crate nalgebra as na;
mod cache;
mod candidates;
+mod cmd;
mod cost;
mod paths;
mod project;
-#[derive(FromArgs)]
-/// Find the best performing container type using primrose
-struct Args {
- /// path to Cargo.toml
- #[argh(option)]
- manifest_path: Option<String>,
-
- /// project to run on, if in a workspace
- #[argh(option, short = 'p')]
- project: Option<String>,
-}
-
fn main() -> Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
@@ -37,28 +27,23 @@ fn main() -> Result<()> {
let projects = get_projects(&args).context("failed to find project paths")?;
- let candidates = CandidatesStore::new(&paths)?;
- let benchmarks = ResultsStore::new(&paths)?;
-
- let mut seen_types = HashSet::new();
- for project in projects {
- info!("Processing {}", &project.name);
-
- let all_candidates = project.get_all_candidates(&candidates)?;
- info!("Found candidates: {:?}", all_candidates);
- for (_, candidates) in all_candidates.iter() {
- for candidate in candidates {
- seen_types.insert(candidate.clone());
- }
- }
+ match args.cmd {
+ Subcommand::Model(c) => cmd_model(paths, projects, c),
+ Subcommand::Candidates(c) => cmd_candidates(paths, projects, c),
+ Subcommand::Profile(c) => cmd_profile(paths, projects, c),
}
+}
- info!("Found all candidate types. Running benchmarks");
- for typ in seen_types.into_iter() {
- let _results = dbg!(benchmarks.get(&typ).context("Error building cost model")?);
- }
+fn cmd_model(paths: Paths, projects: Vec<Project>, c: ModelSubcommand) -> Result<()> {
+ todo!()
+}
+
+fn cmd_candidates(paths: Paths, projects: Vec<Project>, c: CandidatesSubcommand) -> Result<()> {
+ todo!()
+}
- Ok(())
+fn cmd_profile(paths: Paths, projects: Vec<Project>, c: ProfileSubcommand) -> Result<()> {
+ todo!()
}
fn get_projects(args: &Args) -> Result<Vec<Project>> {