2017-08-18 12:12:25 +02:00
|
|
|
import json
|
2017-11-16 10:12:16 +01:00
|
|
|
import multiprocessing
|
2017-08-18 12:12:25 +02:00
|
|
|
import platform
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2017-11-16 10:12:16 +01:00
|
|
|
# Usually comes from third_party
|
|
|
|
import cpuinfo
|
|
|
|
import cpu_cores
|
2017-08-18 12:12:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
2017-11-16 10:12:16 +01:00
|
|
|
cores_info = cpu_cores.CPUCoresCounter.factory()
|
2017-08-18 12:12:25 +02:00
|
|
|
system_info['cpu_brand'] = cpu_info['brand']
|
2017-11-16 10:12:16 +01:00
|
|
|
system_info["num_cpu_cores"] = cores_info.get_physical_cores_count()
|
|
|
|
system_info["num_cpu_threads"] = multiprocessing.cpu_count()
|
|
|
|
system_info["num_cpu_sockets"] = cores_info.get_physical_processors_count()
|
2017-08-18 12:12:25 +02:00
|
|
|
system_info['devices'] = _getBlenderDeviceInfo(ctx)
|
|
|
|
# TODO(sergey): query number of CPUs and threads.
|
|
|
|
return system_info
|