-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_core_affinity.rs
More file actions
39 lines (33 loc) · 1.27 KB
/
test_core_affinity.rs
File metadata and controls
39 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use core_affinity;
fn main() {
println!("Testing core_affinity crate...");
// Get available cores
if let Some(cores) = core_affinity::get_core_ids() {
println!("Available cores: {:?}", cores);
println!("Number of cores: {}", cores.len());
// Try to set affinity to core 3
if let Some(core) = cores.get(3) {
println!("Attempting to set affinity to core 3 (CoreId: {:?})", core);
if core_affinity::set_for_current(*core) {
println!("SUCCESS: Set affinity to core 3");
} else {
println!("FAILED: Could not set affinity to core 3");
}
} else {
println!("ERROR: Core 3 not available");
}
// Try to set affinity to core 2
if let Some(core) = cores.get(2) {
println!("Attempting to set affinity to core 2 (CoreId: {:?})", core);
if core_affinity::set_for_current(*core) {
println!("SUCCESS: Set affinity to core 2");
} else {
println!("FAILED: Could not set affinity to core 2");
}
} else {
println!("ERROR: Core 2 not available");
}
} else {
println!("ERROR: Could not get core IDs");
}
}