aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_prof/src/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index da541005a..c7973ddf4 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -106,6 +106,21 @@ pub fn profile(desc: &str) -> Profiler {
106 }) 106 })
107} 107}
108 108
109pub fn print_time(desc: &str) -> impl Drop + '_ {
110 struct Guard<'a> {
111 desc: &'a str,
112 start: Instant,
113 }
114
115 impl Drop for Guard<'_> {
116 fn drop(&mut self) {
117 eprintln!("{}: {:?}", self.desc, self.start.elapsed())
118 }
119 }
120
121 Guard { desc, start: Instant::now() }
122}
123
109pub struct Profiler { 124pub struct Profiler {
110 desc: Option<String>, 125 desc: Option<String>,
111} 126}