File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,14 @@ impl StopWatch {
23
23
pub fn start ( ) -> StopWatch {
24
24
#[ cfg( target_os = "linux" ) ]
25
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
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
35
counter
31
36
} ;
@@ -47,7 +52,9 @@ impl StopWatch {
47
52
let time = self . time . elapsed ( ) ;
48
53
49
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
58
#[ cfg( not( target_os = "linux" ) ) ]
52
59
let instructions = None ;
53
60
You can’t perform that action at this time.
0 commit comments