@@ -11,7 +11,7 @@ use crate::MemoryUsage;
1111
1212pub struct StopWatch {
1313time : Instant ,
14- #[ cfg( target_os = "linux" ) ]
14+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
1515counter : Option < perf_event:: Counter > ,
1616memory : MemoryUsage ,
1717}
@@ -24,7 +24,7 @@ pub struct StopWatchSpan {
2424
2525impl StopWatch {
2626pub fn start ( ) -> StopWatch {
27- #[ cfg( target_os = "linux" ) ]
27+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
2828let 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 {
5151let time = Instant :: now ( ) ;
5252StopWatch {
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 {
6060pub fn elapsed ( & mut self ) -> StopWatchSpan {
6161let time = self . time . elapsed ( ) ;
6262
63- #[ cfg( target_os = "linux" ) ]
63+ #[ cfg( all ( target_os = "linux" , not ( target_env = "ohos" ) ) ) ]
6464let 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" ) ) ]
6870let instructions = None ;
6971
0 commit comments