processor_cache/
processor_cache.rs1extern crate hwloc;
2
3use hwloc::{Topology, ObjectType};
4
5fn main() {
8 let topo = Topology::new();
9
10 let pu = topo.objects_with_type(&ObjectType::PU).unwrap()[0];
11
12 let mut parent = pu.parent();
13 let mut levels = 0;
14 let mut size = 0;
15
16 while let Some(p) = parent {
17 if p.object_type() == ObjectType::Cache {
18 levels += 1;
19 size += p.cache_attributes().unwrap().size;
21 }
22 parent = p.parent();
23 }
24
25 println!("*** Logical processor 0 has {} caches totalling {} KB",
26 levels,
27 size / 1024);
28}