20 lines
656 B
Python
20 lines
656 B
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: MIT
|
|
"""Identify the CPU class used for comparable CI microbenchmark baselines."""
|
|
|
|
import os
|
|
import platform
|
|
from pathlib import Path
|
|
|
|
|
|
def identity() -> dict[str, object]:
|
|
model = "unknown"
|
|
cpuinfo = Path("/proc/cpuinfo")
|
|
if cpuinfo.is_file():
|
|
for line in cpuinfo.read_text(errors="replace").splitlines():
|
|
if line.startswith(("model name\t", "Hardware\t", "Processor\t")):
|
|
model = line.partition(":")[2].strip()[:160]
|
|
break
|
|
return {"architecture": platform.machine(), "cpu_model": model,
|
|
"logical_cpus": os.cpu_count() or 1}
|