diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-25 10:59:46 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-25 10:59:46 +0000 |
commit | fb81726ee59a8df5d86ec2a78f959a0e166b8199 (patch) | |
tree | 4bf167645d4b7f098140612086424f6a0de69719 | |
parent | c6dbf406a9bbf1d8df438753c9e1a7c97d0f00e1 (diff) | |
parent | 6577a7622d5053f35c16eed47516265c98e5212e (diff) |
Merge #2903
2903: Add print_time helper r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | Cargo.lock | 10 | ||||
-rw-r--r-- | crates/ra_cli/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_prof/src/lib.rs | 15 |
4 files changed, 17 insertions, 12 deletions
diff --git a/Cargo.lock b/Cargo.lock index db566fdb2..07fff9af5 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -326,7 +326,6 @@ name = "env_logger" | |||
326 | version = "0.7.1" | 326 | version = "0.7.1" |
327 | source = "registry+https://github.com/rust-lang/crates.io-index" | 327 | source = "registry+https://github.com/rust-lang/crates.io-index" |
328 | dependencies = [ | 328 | dependencies = [ |
329 | "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
330 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 329 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
331 | ] | 330 | ] |
332 | 331 | ||
@@ -444,14 +443,6 @@ dependencies = [ | |||
444 | ] | 443 | ] |
445 | 444 | ||
446 | [[package]] | 445 | [[package]] |
447 | name = "humantime" | ||
448 | version = "1.3.0" | ||
449 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
450 | dependencies = [ | ||
451 | "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
452 | ] | ||
453 | |||
454 | [[package]] | ||
455 | name = "idna" | 446 | name = "idna" |
456 | version = "0.2.0" | 447 | version = "0.2.0" |
457 | source = "registry+https://github.com/rust-lang/crates.io-index" | 448 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1830,7 +1821,6 @@ dependencies = [ | |||
1830 | "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" | 1821 | "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" |
1831 | "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" | 1822 | "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" |
1832 | "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" | 1823 | "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" |
1833 | "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" | ||
1834 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" | 1824 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" |
1835 | "checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" | 1825 | "checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" |
1836 | "checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" | 1826 | "checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" |
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index 12af075f7..bcd408421 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml | |||
@@ -7,7 +7,7 @@ publish = false | |||
7 | 7 | ||
8 | [dependencies] | 8 | [dependencies] |
9 | pico-args = "0.3.0" | 9 | 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 } |
11 | 11 | ||
12 | ra_syntax = { path = "../ra_syntax" } | 12 | ra_syntax = { path = "../ra_syntax" } |
13 | ra_ide = { path = "../ra_ide" } | 13 | ra_ide = { path = "../ra_ide" } |
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 4ee3fb49f..5df0496dd 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -26,7 +26,7 @@ lsp-server = "0.3.0" | |||
26 | ra_project_model = { path = "../ra_project_model" } | 26 | ra_project_model = { path = "../ra_project_model" } |
27 | ra_prof = { path = "../ra_prof" } | 27 | ra_prof = { path = "../ra_prof" } |
28 | ra_vfs_glob = { path = "../ra_vfs_glob" } | 28 | 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 } |
30 | ra_cargo_watch = { path = "../ra_cargo_watch" } | 30 | ra_cargo_watch = { path = "../ra_cargo_watch" } |
31 | either = "1.5" | 31 | either = "1.5" |
32 | 32 | ||
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 | ||
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 | |||
109 | pub struct Profiler { | 124 | pub struct Profiler { |
110 | desc: Option<String>, | 125 | desc: Option<String>, |
111 | } | 126 | } |