Changeset View
Changeset View
Standalone View
Standalone View
tests/performance/api/device.py
| # Apache License, Version 2.0 | # Apache License, Version 2.0 | ||||
| import platform | import platform | ||||
| import subprocess | import subprocess | ||||
| from typing import List | from typing import List | ||||
| def get_cpu_name() -> str: | def get_cpu_name() -> str: | ||||
| # Get full CPU name. | # Get full CPU name. | ||||
| if platform.system() == "Windows": | if platform.system() == "Windows": | ||||
| return platform.processor() | return platform.processor() | ||||
| elif platform.system() == "Darwin": | elif platform.system() == "Darwin": | ||||
| cmd = ['/usr/sbin/sysctl', "-n", "machdep.cpu.brand_string"] | cmd = ['/usr/sbin/sysctl', "-n", "machdep.cpu.brand_string"] | ||||
| return subprocess.check_output(cmd).strip().decode('utf-8') | return subprocess.check_output(cmd).strip().decode('utf-8', 'ignore') | ||||
| else: | else: | ||||
| with open('/proc/cpuinfo') as f: | with open('/proc/cpuinfo') as f: | ||||
| for line in f: | for line in f: | ||||
| if line.startswith('model name'): | if line.startswith('model name'): | ||||
| return line.split(':')[1].strip() | return line.split(':')[1].strip() | ||||
| return "Unknown CPU" | return "Unknown CPU" | ||||
| ▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines | |||||