MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / get_cpu_flags

Function get_cpu_flags

src/system/info.rs:64–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62
63#[cfg(target_os = "linux")]
64fn get_cpu_flags() -> Vec<String> {
65 use procfs::Current;
66
67 let cpuinfo = match procfs::CpuInfo::current() {
68 Ok(cpuinfo) => cpuinfo,
69 Err(e) => {
70 warn!("Failed to read /proc/cpuinfo: {e}");
71 return Vec::new();
72 }
73 };
74
75 // /proc/cpuinfo uses "flags" on x86_64 and "Features" on aarch64
76 let field_name = if cfg!(target_arch = "x86_64") {
77 "flags"
78 } else if cfg!(target_arch = "aarch64") {
79 "Features"
80 } else {
81 return Vec::new();
82 };
83
84 let mut flags: Vec<String> = match cpuinfo.get_field(0, field_name) {
85 Some(value) => value.split_whitespace().map(|s| s.to_string()).collect(),
86 None => {
87 warn!("No CPU flags found in /proc/cpuinfo (field: {field_name})");
88 return Vec::new();
89 }
90 };
91 flags.sort();
92 flags
93}
94
95#[cfg(not(target_os = "linux"))]
96fn get_cpu_flags() -> Vec<String> {

Callers 1

newMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected