diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-30 13:34:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-30 13:34:38 +0100 |
commit | 96c3ff1c573f97e5089fc0ba01ede6fe43693668 (patch) | |
tree | 3a01617f8b4bb867e294feff1acc10609755ef56 /crates | |
parent | 5844dd0bb4e30d96156f6ee1cb7dc097a51e5610 (diff) | |
parent | 3e1e6227ca525f8631e0bff2215fa3de1b4f4cc1 (diff) |
Merge #5588
5588: Print errors when failing to create a perf counter r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_prof/src/stop_watch.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_prof/src/stop_watch.rs b/crates/ra_prof/src/stop_watch.rs index 8b8ec25a5..5e276190e 100644 --- a/crates/ra_prof/src/stop_watch.rs +++ b/crates/ra_prof/src/stop_watch.rs | |||
@@ -23,9 +23,14 @@ impl StopWatch { | |||
23 | pub fn start() -> StopWatch { | 23 | pub fn start() -> StopWatch { |
24 | #[cfg(target_os = "linux")] | 24 | #[cfg(target_os = "linux")] |
25 | let counter = { | 25 | let counter = { |
26 | let mut counter = perf_event::Builder::new().build().ok(); | 26 | let mut counter = perf_event::Builder::new() |
27 | .build() | ||
28 | .map_err(|err| eprintln!("Failed to create perf counter: {}", err)) | ||
29 | .ok(); | ||
27 | if let Some(counter) = &mut counter { | 30 | if let Some(counter) = &mut counter { |
28 | let _ = counter.enable(); | 31 | if let Err(err) = counter.enable() { |
32 | eprintln!("Failed to start perf counter: {}", err) | ||
33 | } | ||
29 | } | 34 | } |
30 | counter | 35 | counter |
31 | }; | 36 | }; |
@@ -47,7 +52,9 @@ impl StopWatch { | |||
47 | let time = self.time.elapsed(); | 52 | let time = self.time.elapsed(); |
48 | 53 | ||
49 | #[cfg(target_os = "linux")] | 54 | #[cfg(target_os = "linux")] |
50 | let instructions = self.counter.as_mut().and_then(|it| it.read().ok()); | 55 | let instructions = self.counter.as_mut().and_then(|it| { |
56 | it.read().map_err(|err| eprintln!("Failed to read perf counter: {}", err)).ok() | ||
57 | }); | ||
51 | #[cfg(not(target_os = "linux"))] | 58 | #[cfg(not(target_os = "linux"))] |
52 | let instructions = None; | 59 | let instructions = None; |
53 | 60 | ||