Skip to content

Commit fb81726

Browse files
bors[bot]matklad
andauthored
Merge #2903
2903: Add print_time helper r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents c6dbf40 + 6577a76 commit fb81726

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77

88
[dependencies]
99
pico-args = "0.3.0"
10-
env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] }
10+
env_logger = { version = "0.7.1", default-features = false }
1111

1212
ra_syntax = { path = "../ra_syntax" }
1313
ra_ide = { path = "../ra_ide" }

crates/ra_lsp_server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lsp-server = "0.3.0"
2626
ra_project_model = { path = "../ra_project_model" }
2727
ra_prof = { path = "../ra_prof" }
2828
ra_vfs_glob = { path = "../ra_vfs_glob" }
29-
env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] }
29+
env_logger = { version = "0.7.1", default-features = false }
3030
ra_cargo_watch = { path = "../ra_cargo_watch" }
3131
either = "1.5"
3232

crates/ra_prof/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ pub fn profile(desc: &str) -> Profiler {
106106
})
107107
}
108108

109+
pub 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+
109124
pub struct Profiler {
110125
desc: Option<String>,
111126
}

0 commit comments

Comments
 (0)