Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/lib/src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,23 @@ fn write_model_name(w: &mut StackWriter) {
};
let data = &buf[..n];

let found = if let Some(name) = extract_name(data) {
w.push_str(name);
true
} else {
write_dt_compatible(w)
};
if !found {
let name = extract_name(data);
if name.is_none() && !write_dt_compatible(w) {
return;
}

if let Some(mhz) = get_cpu_freq_mhz() {
let mhz = get_cpu_freq_mhz();
if let Some(name) = name {
// x86 `model name` already ends in `@ <clock>GHz`, which hides the
// ` CPU` that trim() would otherwise strip, so re-trim after cutting.
let name = match (mhz, name.find(" @ ")) {
(Some(_), Some(at)) => trim(&name[..at]),
_ => name,
};
w.push_str(name);
}

if let Some(mhz) = mhz {
w.push_str(" @ ");
// Round to nearest 0.01 GHz, then split so carries (e.g. 1999 MHz)
// roll into the integer part instead of overflowing the fraction.
Expand Down
Loading