mirror of
https://github.com/starship/starship.git
synced 2026-06-24 02:01:36 +07:00
feat: Add timings subcommand (#1629)
* feat: Add computational duration to all computed modules
This also means that in case we do some computations and these end up empty, we submit an empty module
* feat: Add timings subcommand
This outputs the timings of all computed modules, sorted by the duration it took to compute the module.
Useful for debugging why the prompt takes so long.
* feat: Add timings to explain output
* fix: Ensure that even empty custom modules get timings
* format main.rs
* feat: Only show interesting timings
* fix(tests): Change tests to look for empty string instead of None
* Use proper wording in timings help
* Revert "fix(tests): Change tests to look for empty string instead of None"
This reverts commit aca5bd1b03.
* fix(tests): Returning None in case the module produced an empty string
* fix: Ensure that linebreaks (and space) make a module not-empty
* Make cargo clippy happy
* Make Module.duration a proper Duration
* Only return a module if we would report it
* Change to cleaner way to return None for empty modules
* Avoid unnecessary module creation
* Simplify a string comparison
* Add timings to trace
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
This commit is contained in:
+6
-1
@@ -84,7 +84,12 @@ impl<'a> ModuleRenderer<'a> {
|
||||
|
||||
/// Renders the module returning its output
|
||||
pub fn collect(self) -> Option<String> {
|
||||
crate::print::get_module(self.name, self.context)
|
||||
let ret = crate::print::get_module(self.name, self.context);
|
||||
// all tests rely on the fact that an empty module produces None as output as the
|
||||
// convention was that there would be no module but None. This is nowadays not anymore
|
||||
// the case (to get durations for all modules). So here we make it so, that an empty
|
||||
// module returns None in the tests...
|
||||
ret.filter(|s| s != "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user