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