Repository navigation
feat: Print sourcemaps/files operations timings information #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,17 @@ impl ProgressBar { | |
| } | ||
|
|
||
| pub fn finish_with_message(&self, msg: &str) { | ||
| self.inner.finish_with_message(msg.to_owned()); | ||
| logging::set_progress_bar(None); | ||
| } | ||
|
|
||
| pub fn finish_with_duration(&self, op: &str) { | ||
|
AbhiPrasad marked this conversation as resolved.
Resolved
|
||
| let dur = self.inner.elapsed(); | ||
| // We could use `dur.as_secs_f64()`, but its unnecessarily precise (micros). Millis are enough for our purpose. | ||
| let msg = format!("{} completed in {}s", op, dur.as_millis() as f64 / 1000.0); | ||
| let progress_style = ProgressStyle::default_bar().template("{prefix:.dim} {msg}"); | ||
| self.inner.set_style(progress_style); | ||
| self.inner.set_prefix(">"); | ||
| self.inner.finish_with_message(msg); | ||
| logging::set_progress_bar(None); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about it but decided no to do that to keep everything in line. This way, every method is a standalone thing that just proxies data to |
||
| } | ||
|
|
@@ -76,7 +87,7 @@ impl Deref for ProgressBar { | |
|
|
||
| pub fn make_progress_bar(len: u64) -> ProgressBar { | ||
| let pb = ProgressBar::new(len); | ||
| pb.set_draw_target(ProgressDrawTarget::to_term(Term::stdout(), None)); | ||
| pb.set_draw_target(ProgressDrawTarget::term(Term::stdout(), None)); | ||
| pb.set_style(ProgressStyle::default_bar().template(&format!( | ||
| "{} {{msg}}\n{{wide_bar}} {{pos}}/{{len}}", | ||
| style(">").cyan() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust Q, do we always prefer
to_ownedoverclonebecause it's more generic? (to_ownedmight not clone right? - depends on the trait impl)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clone()on&strreturns a&str, where in this caseto_ownedwill returnStringwhich we need forset_message. I preferto_ownedas it's more explicit and obvious what are you want to get out of that call.