aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-02-27 02:46:36 -0500
committerJesse Luehrs <doy@tozt.net>2018-02-27 02:59:19 -0500
commitaa45fae4852080b7f7289408248499b3cecc8169 (patch)
treea9591429d0d0fa704ff66d929011d5d7097d0d17
parentbea8eb55cb26db5dc50958665668759716ff6830 (diff)
downloadfancy-prompt-aa45fae4852080b7f7289408248499b3cecc8169.tar.gz
fancy-prompt-aa45fae4852080b7f7289408248499b3cecc8169.zip
add some more profiling verbose output
-rw-r--r--src/main.rs66
-rw-r--r--src/vcs/git.rs9
2 files changed, 56 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index 2a748cf..2f9063e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,6 +18,8 @@ mod system_info;
mod vcs;
fn collect_data() -> prompt::PromptData {
+ start_talking_about_time!("collecting data");
+
let matches = clap::App::new("fancy-prompt")
.about("Prints a fancy prompt")
// XXX author, version (extract from cargo)
@@ -32,29 +34,57 @@ fn collect_data() -> prompt::PromptData {
)
.get_matches();
+ let shell = matches
+ .value_of("prompt-escape")
+ .map(|shell| colors::ShellType::from_str(shell))
+ .unwrap_or(colors::ShellType::Unknown);
+ let error_code = matches
+ .value_of("error-code")
+ .map(|code| code.parse().expect("error code must be a u8"))
+ .unwrap_or(0);
+ talk_about_time!("command line arg parsing");
+
+ let hostname = system_info::hostname();
+ talk_about_time!("hostname");
+ let terminal_cols = system_info::terminal_cols();
+ talk_about_time!("terminal_cols");
+ let pwd = system_info::pwd();
+ talk_about_time!("pwd");
+ let home = system_info::home();
+ talk_about_time!("home");
+ let user = system_info::user();
+ talk_about_time!("user");
+ let is_root = system_info::is_root();
+ talk_about_time!("is_root");
+ let time = system_info::time();
+ talk_about_time!("time");
+ let power_info = system_info::power_info();
+ talk_about_time!("power_info");
+ let vcs_info = system_info::vcs_info();
+ talk_about_time!("vcs_info");
+
+ stop_talking_about_time!();
+
prompt::PromptData {
- shell: matches
- .value_of("prompt-escape")
- .map(|shell| colors::ShellType::from_str(shell))
- .unwrap_or(colors::ShellType::Unknown),
- error_code: matches
- .value_of("error-code")
- .map(|code| code.parse().expect("error code must be a u8"))
- .unwrap_or(0),
-
- hostname: system_info::hostname(),
- terminal_cols: system_info::terminal_cols(),
- pwd: system_info::pwd(),
- home: system_info::home(),
- user: system_info::user(),
- is_root: system_info::is_root(),
- time: system_info::time(),
- power_info: system_info::power_info(),
- vcs_info: system_info::vcs_info(),
+ shell,
+ error_code,
+ hostname,
+ terminal_cols,
+ pwd,
+ home,
+ user,
+ is_root,
+ time,
+ power_info,
+ vcs_info,
}
}
fn main() {
+ start_talking_about_time!("main");
let data = collect_data();
+ talk_about_time!("collecting data");
prompt::Prompt::new(data).display();
+ talk_about_time!("displaying data");
+ stop_talking_about_time!();
}
diff --git a/src/vcs/git.rs b/src/vcs/git.rs
index 32369a3..74696ec 100644
--- a/src/vcs/git.rs
+++ b/src/vcs/git.rs
@@ -187,9 +187,16 @@ impl super::VcsInfo for GitInfo {
}
pub fn detect() -> Option<Box<super::VcsInfo>> {
- let git = std::env::current_dir()
+ start_talking_about_time!("git::detect");
+
+ let pwd = std::env::current_dir();
+ talk_about_time!("pwd");
+ let git = pwd
.ok()
.and_then(|pwd| git2::Repository::discover(pwd).ok());
+ talk_about_time!("discover");
+
+ stop_talking_about_time!();
if let Some(git) = git {
Some(Box::new(GitInfo::new(&git)))