Initial commit
This commit is contained in:
73
benchmark/foundation/system_info.py
Normal file
73
benchmark/foundation/system_info.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import json
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from third_party import cpuinfo
|
||||
|
||||
|
||||
def _getBlenderDeviceInfo(ctx):
|
||||
PREFIX = "Benchmark Devices: "
|
||||
command = [ctx.blender,
|
||||
"--background",
|
||||
"--factory-startup",
|
||||
"-noaudio",
|
||||
"--enable-autoexec",
|
||||
"--engine", "CYCLES",
|
||||
"--python", ctx.configure_script,
|
||||
"--",
|
||||
"--benchmark-system-info"]
|
||||
process = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
stdout, stderr = process.communicate()
|
||||
lines = stdout.decode().split("\n")
|
||||
for line in lines:
|
||||
if line.startswith(PREFIX):
|
||||
return json.loads(line[len(PREFIX):])
|
||||
return []
|
||||
|
||||
|
||||
def getBlenderVersion(ctx):
|
||||
INFO = ("build_date",
|
||||
"build_time",
|
||||
"build_commit_date",
|
||||
"build_commit_time",
|
||||
"build_hash")
|
||||
command = [ctx.blender, "--version"]
|
||||
process = subprocess.Popen(command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
stdout, stderr = process.communicate()
|
||||
lines = stdout.decode().split("\n")
|
||||
info = {}
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line.startswith("Blender "):
|
||||
version = line[8:].strip()
|
||||
info['version'] = version
|
||||
if not line.startswith("build "):
|
||||
continue
|
||||
tokens = line.split(":", 1)
|
||||
tokens[0] = tokens[0].replace(" ", "_")
|
||||
if tokens[0] in INFO:
|
||||
info[tokens[0]] = tokens[1].strip()
|
||||
return info
|
||||
|
||||
|
||||
def gatherSystemInfo(ctx):
|
||||
system_info = {}
|
||||
system_info['bitness'] = platform.architecture()[0]
|
||||
system_info['machine'] = platform.machine()
|
||||
system_info['system'] = platform.system()
|
||||
if system_info['system'] == "Linux":
|
||||
distro = platform.linux_distribution()
|
||||
system_info['dist_name'] = distro[0]
|
||||
system_info['dist_version'] = distro[1]
|
||||
# system_info['libc_version'] = "-".join(platform.libc_ver())
|
||||
# TODO(sergey): Make this to work on Windows and macOS
|
||||
cpu_info = cpuinfo.get_cpu_info()
|
||||
system_info['cpu_brand'] = cpu_info['brand']
|
||||
system_info['devices'] = _getBlenderDeviceInfo(ctx)
|
||||
# TODO(sergey): query number of CPUs and threads.
|
||||
return system_info
|
Reference in New Issue
Block a user