@@ -11,7 +11,7 @@ use crate::MemoryUsage;
1111
1212pub struct StopWatch {
1313 time : Instant ,
14- #[ cfg( target_os = "linux" ) ]
14+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
1515 counter : Option < perf_event:: Counter > ,
1616 memory : MemoryUsage ,
1717}
@@ -24,7 +24,7 @@ pub struct StopWatchSpan {
2424
2525impl StopWatch {
2626 pub fn start ( ) -> StopWatch {
27- #[ cfg( target_os = "linux" ) ]
27+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
2828 let counter = {
2929 // When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort.
3030 // We allow disabling perf by setting the env var `RA_DISABLE_PERF`.
@@ -51,7 +51,7 @@ impl StopWatch {
5151 let time = Instant :: now ( ) ;
5252 StopWatch {
5353 time,
54- #[ cfg( target_os = "linux" ) ]
54+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
5555 counter,
5656 memory,
5757 }
@@ -60,10 +60,12 @@ impl StopWatch {
6060 pub fn elapsed ( & mut self ) -> StopWatchSpan {
6161 let time = self . time . elapsed ( ) ;
6262
63- #[ cfg( target_os = "linux" ) ]
63+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
6464 let instructions = self . counter . as_mut ( ) . and_then ( |it| {
6565 it. read ( ) . map_err ( |err| eprintln ! ( "Failed to read perf counter: {err}" ) ) . ok ( )
6666 } ) ;
67+ #[ cfg( all( target_os = "linux" , target_env = "ohos" ) ) ]
68+ let instructions = None ;
6769 #[ cfg( not( target_os = "linux" ) ) ]
6870 let instructions = None ;
6971
0 commit comments