Skip to content

Commit

Permalink
fix cpu names
Browse files Browse the repository at this point in the history
  • Loading branch information
Prevter committed Sep 23, 2023
1 parent f38c363 commit ae88810
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
34 changes: 10 additions & 24 deletions FloatTool/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static string FirstCharToUpper(this string input) =>
};
}

public static class Utils
public static partial class Utils
{
public static string API_URL = "";
public static string HOME_URL = "";
Expand Down Expand Up @@ -179,31 +179,17 @@ public static async Task<UpdateResult> CheckForUpdates()
}
}

[GeneratedRegex(@"(?:\d{1,}th Gen)?(?:Genuine)? ?(?'vendor'AMD|Intel|Qualcomm|Samsung|MediaTek)(?:\(R\)|\(r\))? (?'family'[a-zA-Z]*)(?:\(TM\)|\(tm\))?(?'model'.*?)( [a-zA-Z]{1,}-Core| with| CPU @| @|$)")]
private static partial Regex CpuNameRegex();

public static string ShortCpuName(string cpu)
{
cpu = cpu.Replace("(R)", "");
cpu = cpu.Replace("(TM)", "");
cpu = cpu.Replace("(tm)", "");
cpu = cpu.Replace(" with Radeon Graphics", "");
cpu = cpu.Replace(" with Radeon Vega Mobile Gfx", "");
cpu = cpu.Replace(" CPU", "");
cpu = cpu.Replace(" Processor", "");

Regex regex = new(@"( \S{1,}-Core)");
MatchCollection matches = regex.Matches(cpu);
if (matches.Count > 0)
foreach (Match match in matches.Cast<Match>())
cpu = cpu.Replace(match.Value, "");

var index = cpu.IndexOf('@');
if (index != -1)
cpu = cpu[..index];

index = cpu.IndexOf('(');
if (index != -1)
cpu = cpu[..index];

return cpu.Trim();
Regex regex = CpuNameRegex();
Match match = regex.Match(cpu);
string vendor = match.Groups["vendor"].Value;
string family = match.Groups["family"].Value;
string model = match.Groups["model"].Value;
return $"{vendor} {family}{model}";
}

public static string EscapeLocalization(string input)
Expand Down
2 changes: 1 addition & 1 deletion FloatTool/ViewModels/BenchmarkViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async void PollBenchmarkResults()
MultithreadedSpeed = Math.Max((int)benchmark.multithread, MultithreadedSpeed);
SinglethreadedSpeed = Math.Max((int)benchmark.singlethread, SinglethreadedSpeed);
}
else if (cpuName.StartsWith("Intel"))
else if (cpuName.Contains("Intel"))
currentFill = IntelBrush;

BenchmarkResults.Add(new BenchmarkResult
Expand Down

0 comments on commit ae88810

Please sign in to comment.