perf: get_cpu_model_count

pull/15852/head
feng 2025-08-15 16:39:19 +08:00 committed by ZhaoJiSen
parent 7d06819bbe
commit 21126de2c1
1 changed files with 8 additions and 3 deletions

View File

@ -11,15 +11,20 @@ class FormatAssetInfo:
@staticmethod
def get_cpu_model_count(cpus):
try:
models = [cpus[i + 1] + " " + cpus[i + 2] for i in range(0, len(cpus), 3)]
if len(cpus) % 3 == 0:
step = 3
models = [cpus[i + 2] for i in range(0, len(cpus), step)]
elif len(cpus) % 2 == 0:
step = 2
models = [cpus[i + 1] for i in range(0, len(cpus), step)]
else:
raise ValueError("CPU list format not recognized")
model_counts = Counter(models)
result = ', '.join([f"{model} x{count}" for model, count in model_counts.items()])
except Exception as e:
print(f"Error processing CPU model list: {e}")
result = ''
return result
@staticmethod