Fix CPU model extraction for newer Intel generations
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m24s
- Handle 12th/13th Gen Intel format (e.g., "12th Gen Intel(R) Core(TM) i7-12700K") - Extract full model including suffix (i7-12700K instead of truncated name) - Simplify pattern matching logic - Reduce fallback truncation to 15 chars
This commit is contained in:
@@ -152,27 +152,17 @@ impl CpuCollector {
|
||||
/// Extract CPU model number from full model name
|
||||
/// Examples:
|
||||
/// - "Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz" -> "i7-9700"
|
||||
/// - "12th Gen Intel(R) Core(TM) i7-12700K" -> "i7-12700K"
|
||||
/// - "AMD Ryzen 9 5950X 16-Core Processor" -> "Ryzen 9 5950X"
|
||||
fn extract_cpu_model(full_name: &str) -> String {
|
||||
// Look for common Intel patterns: i3, i5, i7, i9, Xeon
|
||||
if let Some(pos) = full_name.find("i3-") {
|
||||
if let Some(end) = full_name[pos..].find(' ') {
|
||||
return full_name[pos..pos + end].to_string();
|
||||
}
|
||||
}
|
||||
if let Some(pos) = full_name.find("i5-") {
|
||||
if let Some(end) = full_name[pos..].find(' ') {
|
||||
return full_name[pos..pos + end].to_string();
|
||||
}
|
||||
}
|
||||
if let Some(pos) = full_name.find("i7-") {
|
||||
if let Some(end) = full_name[pos..].find(' ') {
|
||||
return full_name[pos..pos + end].to_string();
|
||||
}
|
||||
}
|
||||
if let Some(pos) = full_name.find("i9-") {
|
||||
if let Some(end) = full_name[pos..].find(' ') {
|
||||
return full_name[pos..pos + end].to_string();
|
||||
// Look for Intel Core patterns (both old and new gen): i3, i5, i7, i9
|
||||
// Match pattern like "i7-12700K" or "i7-9700"
|
||||
for prefix in &["i3-", "i5-", "i7-", "i9-"] {
|
||||
if let Some(pos) = full_name.find(prefix) {
|
||||
// Find end of model number (until space or end of string)
|
||||
let after_prefix = &full_name[pos..];
|
||||
let end = after_prefix.find(' ').unwrap_or(after_prefix.len());
|
||||
return after_prefix[..end].to_string();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,9 +176,9 @@ impl CpuCollector {
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: return first 20 characters or full name if shorter
|
||||
if full_name.len() > 20 {
|
||||
full_name[..20].to_string()
|
||||
// Fallback: return first 15 characters or full name if shorter
|
||||
if full_name.len() > 15 {
|
||||
full_name[..15].to_string()
|
||||
} else {
|
||||
full_name.to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user