@@ -11,7 +11,11 @@ use crate::MemoryUsage;
1111
1212pub struct StopWatch {
1313 time : Instant ,
14- #[ cfg( all( target_os = "linux" , not( target_env = "ohos" ) ) ) ]
14+ #[ cfg( all(
15+ target_os = "linux" ,
16+ not( target_env = "ohos" ) ,
17+ any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
18+ ) ) ]
1519 counter : Option < perf_event:: Counter > ,
1620 memory : MemoryUsage ,
1721}
@@ -24,7 +28,11 @@ pub struct StopWatchSpan {
2428
2529impl StopWatch {
2630 pub fn start ( ) -> StopWatch {
27- #[ cfg( all( target_os = "linux" , not( target_env = "ohos" ) ) ) ]
31+ #[ cfg( all(
32+ target_os = "linux" ,
33+ not( target_env = "ohos" ) ,
34+ any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
35+ ) ) ]
2836 let counter = {
2937 // When debugging rust-analyzer using rr, the perf-related syscalls cause it to abort.
3038 // We allow disabling perf by setting the env var `RA_DISABLE_PERF`.
@@ -51,7 +59,11 @@ impl StopWatch {
5159 let time = Instant :: now ( ) ;
5260 StopWatch {
5361 time,
54- #[ cfg( all( target_os = "linux" , not( target_env = "ohos" ) ) ) ]
62+ #[ cfg( all(
63+ target_os = "linux" ,
64+ not( target_env = "ohos" ) ,
65+ any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
66+ ) ) ]
5567 counter,
5668 memory,
5769 }
@@ -60,13 +72,19 @@ impl StopWatch {
6072 pub fn elapsed ( & mut self ) -> StopWatchSpan {
6173 let time = self . time . elapsed ( ) ;
6274
63- #[ cfg( all( target_os = "linux" , not( target_env = "ohos" ) ) ) ]
75+ #[ cfg( all(
76+ target_os = "linux" ,
77+ not( target_env = "ohos" ) ,
78+ any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
79+ ) ) ]
6480 let instructions = self . counter . as_mut ( ) . and_then ( |it| {
6581 it. read ( ) . map_err ( |err| eprintln ! ( "Failed to read perf counter: {err}" ) ) . ok ( )
6682 } ) ;
67- #[ cfg( all( target_os = "linux" , target_env = "ohos" ) ) ]
68- let instructions = None ;
69- #[ cfg( not( target_os = "linux" ) ) ]
83+ #[ cfg( not( all(
84+ target_os = "linux" ,
85+ not( target_env = "ohos" ) ,
86+ any( target_arch = "x86" , target_arch = "x86_64" , target_arch = "aarch64" )
87+ ) ) ) ]
7088 let instructions = None ;
7189
7290 let memory = MemoryUsage :: now ( ) - self . memory ;
0 commit comments