@@ -11,7 +11,7 @@ use crate::MemoryUsage;
11
11
12
12
pub struct StopWatch {
13
13
time : Instant ,
14
- #[ cfg( target_os = "linux" ) ]
14
+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
15
15
counter : Option < perf_event:: Counter > ,
16
16
memory : MemoryUsage ,
17
17
}
@@ -24,7 +24,7 @@ pub struct StopWatchSpan {
24
24
25
25
impl StopWatch {
26
26
pub fn start ( ) -> StopWatch {
27
- #[ cfg( target_os = "linux" ) ]
27
+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
28
28
let counter = {
29
29
// When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort.
30
30
// We allow disabling perf by setting the env var `RA_DISABLE_PERF`.
@@ -51,7 +51,7 @@ impl StopWatch {
51
51
let time = Instant :: now ( ) ;
52
52
StopWatch {
53
53
time,
54
- #[ cfg( target_os = "linux" ) ]
54
+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
55
55
counter,
56
56
memory,
57
57
}
@@ -60,10 +60,12 @@ impl StopWatch {
60
60
pub fn elapsed ( & mut self ) -> StopWatchSpan {
61
61
let time = self . time . elapsed ( ) ;
62
62
63
- #[ cfg( target_os = "linux" ) ]
63
+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
64
64
let instructions = self . counter . as_mut ( ) . and_then ( |it| {
65
65
it. read ( ) . map_err ( |err| eprintln ! ( "Failed to read perf counter: {err}" ) ) . ok ( )
66
66
} ) ;
67
+ #[ cfg( all( target_os = "linux" , target_env = "ohos" ) ) ]
68
+ let instructions = None ;
67
69
#[ cfg( not( target_os = "linux" ) ) ]
68
70
let instructions = None ;
69
71
0 commit comments