Update superposition (#35)

This commit is contained in:
nharris-lmg
2023-09-20 09:00:50 -07:00
committed by GitHub
parent 67a4e6fe2b
commit 8f685f178b
2 changed files with 38 additions and 39 deletions

View File

@@ -1,15 +1,15 @@
# FurMark Test Harness
# Unigine Superposition benchmark
Wrapper for the Unigine benchmark Superposition.
## Prerequisites
- Python 3.10+
- Unigine Superposition Pro installed in default path.
- [Unigine Superposition](https://benchmark.unigine.com/superposition) installed.
This harness expects that Unigine Superposition Pro has been installed on the system using installer defaults.
> Note: Hopefully it will install itself in the future if not present.
## Output
## Setup
1. Follow the setup instructions for the framework. If you have done so, all required python dependencies *should* be installed.
2. Install MSI Kombuster from [https://benchmark.unigine.com/superposition](https://benchmark.unigine.com/superposition)
1. Follow the installer's defaults.
report.json
- `api`: graphics api to be used: directx or opengl.
- `preset`: graphics preset to be used: low, medium, high, extreme.
- `resolution` resolution to be used, example: 1080,1920

View File

@@ -1,9 +1,11 @@
"""Superposition test script"""
from argparse import ArgumentParser
from subprocess import Popen
import json
import re
import os
import logging
import sys
avail_presets = [
"low",
@@ -17,20 +19,6 @@ avail_presets = [
INSTALL_DIR = "C:\\Program Files\\Unigine\\Superposition Benchmark\\bin"
EXECUTABLE = "superposition_cli.exe"
script_dir = os.path.dirname(os.path.realpath(__file__))
log_dir = os.path.join(script_dir, "run")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
logging_format = '%(asctime)s %(levelname)-s %(message)s'
logging.basicConfig(filename=f'{log_dir}/harness.log',
format=logging_format,
datefmt='%m-%d %H:%M',
level=logging.DEBUG)
console = logging.StreamHandler()
formatter = logging.Formatter(logging_format)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
parser = ArgumentParser()
parser.add_argument("-a", "--api", dest="api",
help="graphics api", metavar="api", required=True)
@@ -43,13 +31,27 @@ args = parser.parse_args()
if args.preset not in avail_presets:
raise ValueError(f"Error, unknown preset: {args.preset}")
match = re.search("^\d+,\d+$", args.resolution)
match = re.search(r"^\d+,\d+$", args.resolution)
if match is None:
raise ValueError("Resolution value must be in format height,width")
r = args.resolution.split(",")
h = r[0]
w = r[1]
script_dir = os.path.dirname(os.path.realpath(__file__))
log_dir = os.path.join(script_dir, "run")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
LOGGING_FORMAT = '%(asctime)s %(levelname)-s %(message)s'
logging.basicConfig(filename=f'{log_dir}/harness.log',
format=LOGGING_FORMAT,
datefmt='%m-%d %H:%M',
level=logging.DEBUG)
console = logging.StreamHandler()
formatter = logging.Formatter(LOGGING_FORMAT)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
cmd = f'{INSTALL_DIR}\\{EXECUTABLE}'
argstr = f"-fullscreen 1 -mode default -api {args.api} -quality {args.preset} -resolution {w}x{h}"
argstr += f" -log_txt {log_dir}\\log.txt"
@@ -59,29 +61,26 @@ logging.info(argstr)
argies = argstr.split(" ")
cmd = cmd.rstrip()
process = Popen([cmd, *argies])
exit_code = process.wait()
EXIT_CODE = process.wait()
if exit_code > 0:
if EXIT_CODE > 0:
logging.error("Test failed!")
exit(exit_code)
sys.exit(EXIT_CODE)
pattern = re.compile(r"Score: (\d+)")
log_path = os.path.join(log_dir, "log.txt")
log = open(log_path)
lines = log.readlines()
for line in lines:
match = pattern.search(line)
if match:
score = match.group(1)
log.close()
with open(log_path, encoding="utf-8") as log:
lines = log.readlines()
for line in lines:
match = pattern.search(line)
if match:
score = match.group(1)
result = {
report = {
"resolution": f"{w}x{h}",
"graphics_preset": args.preset,
"score": score
}
f = open(os.path.join(log_dir, "report.json"), "w")
f.write(json.dumps(result))
f.close()
with open(os.path.join(log_dir, "report.json"), "w", encoding="utf-8") as file:
file.write(json.dumps(report))