diff --git a/msikombuster/README.md b/msikombuster/README.md index 973d65b..b7961da 100644 --- a/msikombuster/README.md +++ b/msikombuster/README.md @@ -5,7 +5,9 @@ This is a wrapper for the [MSI Kombustor](https://geeks3d.com/furmark/kombustor/ ![Alt text](msi_kombustor.png) -This harness takes in the **Stess Test** and **Resolution** as command line arguments and then executes. If started in benchmark mode the score will be recorded. If not in Benchmark mode MSI Kombustor will run until manually exited. +This harness takes in the **Test** and **Resolution** as command line arguments and then executes. If started in benchmark mode the score will be recorded. If not in Benchmark mode MSI Kombustor will run until manually exited. + +The test script utilizes the `-width`, `-height`, `-benchmark`, `-` and `-logfile_in_app_folder` cli options. See the `msi-kombustor-technical-guide.pdf` included with the MSI Kombustor installation for a full list of supported options. ## Prerequisites diff --git a/msikombuster/msi_kombustor_utils.py b/msikombuster/msi_kombustor_utils.py new file mode 100644 index 0000000..6c83300 --- /dev/null +++ b/msikombuster/msi_kombustor_utils.py @@ -0,0 +1,74 @@ +"""Utility functions for MSI Kombustor test script""" +from argparse import ArgumentParser, Namespace +import re + +# cSpell:disable +avail_tests = [ + "vkfurrytorus", + "glfurrytorus", + "vkfurrymsi", + "glfurrymsi", + "glfurmark1700mb", + "glfurmark3200mb", + "glfurmark5200mb", + "glfurmark6500mb", + "glmsi01burn", + "glmsi01", + "glmsi02cpumedium", + "glmsi02cpumedium++", + "glmsi02gpumedium", + "glmsi02gpumedium++", + "glmsi02cpuhard", + "glmsi02gpuhard", + "glphongdonut", + "vkphongdonut", + "glpbrdonut", + "vktessyspherex32", + "vktessyspherex16", + "gltessyspherex32", + "gltessyspherex16", +] +# cSpell:enable + +def parse_args() -> Namespace: + """Gets script arguments""" + parser = ArgumentParser() + parser.add_argument("-t", "--test", dest="test", choices=avail_tests, + help="kombustor test", metavar="test", required=True) + parser.add_argument("-r", "--resolution", dest="resolution", + help="resolution", metavar="resolution", required=True) + parser.add_argument("-b", "--benchmark", dest="benchmark", + help="benchmark mode", metavar="benchmark", required=False) + return parser.parse_args() + + +def parse_resolution(arg: str) -> tuple[str, str]: + """Gets individual height and width values from resolution string""" + match = re.search(r"^\d+,\d+$", arg) + if match is None: + raise ValueError("Resolution value must be in format height,width") + resolution = arg.split(",") + height = resolution[0] + width = resolution[1] + + return height, width + + +def parse_score(log_path: str): + """Parses score value from log file""" + pattern = re.compile(r"score => (\d+)") + with open(log_path, encoding="utf-8") as log: + lines = log.readlines() + for line in reversed(lines): + match = pattern.search(line) + if match: + return match.group(1) + return "N/A" + + +def create_arg_string(width: str, height: str, test: str, benchmark: str) -> str: + """Create string for Kombustor CLI arguments""" + arg_string = f"-width={width} -height={height} -{test} -logfile_in_app_folder " + if benchmark == "true": + arg_string += "-benchmark" + return arg_string diff --git a/msikombuster/msikombuster.py b/msikombuster/msikombuster.py index a2c156a..efa3ec1 100644 --- a/msikombuster/msikombuster.py +++ b/msikombuster/msikombuster.py @@ -1,78 +1,28 @@ -"""Kombustor test script""" -# cSpell:ignore kombustor -from argparse import ArgumentParser +"""MSI Kombustor test script""" from subprocess import Popen -import json -import re import os import logging +import sys +from pathlib import Path +from msi_kombustor_utils import ( + parse_args, + parse_resolution, + parse_score, + create_arg_string +) +PARENT_DIR = str(Path(sys.path[0], "..")) +sys.path.append(PARENT_DIR) -flags = [ - "-width=", - "-height=", - "-benchmark", - "-", - - # Start the artifact scanner - "-scan" - "-tempgraph" - - # Write GPU data (GPU temperature, FPS, etc.) to the log file every second. - "-log_gpu_data" - - # The score file is not updated at the end of a benchmark. - "-update_score_file_disabled" - - # By default the log file is saved in the user’s - # temp folder (C:\Users\USER_NAME\AppData\ - # Local\Temp). This option allows to save the log - # file in Kombustor folder - "-logfile_in_app_folder" -] - -# cSpell:disable -avail_tests = [ - "vkfurrytorus", - "glfurrytorus", - "vkfurrymsi", - "glfurrymsi", - "glfurmark1700mb", - "glfurmark3200mb", - "glfurmark5200mb", - "glfurmark6500mb", - "glmsi01burn", - "glmsi01", - "glmsi02cpumedium", - "glmsi02cpumedium++", - "glmsi02gpumedium", - "glmsi02gpumedium++", - "glmsi02cpuhard", - "glmsi02gpuhard", - "glphongdonut", - "vkphongdonut", - "glpbrdonut", - "vktessyspherex32", - "vktessyspherex16", - "gltessyspherex32", - "gltessyspherex16", -] -# cSpell:enable +from harness_utils.output import ( + write_report_json, + format_resolution +) INSTALL_DIR = r"C:\Program Files\Geeks3D\MSI Kombustor 4 x64" EXECUTABLE = "MSI-Kombustor-x64.exe" -parser = ArgumentParser() -parser.add_argument("-t", "--test", dest="test", - help="kombustor test", metavar="test", required=True) -parser.add_argument("-r", "--resolution", dest="resolution", - help="resolution", metavar="resolution", required=True) -parser.add_argument("-b", "--benchmark", dest="benchmark", - help="benchmark mode", metavar="benchmark", required=False) -args = parser.parse_args() - -if args.test not in avail_tests: - raise ValueError(f"Error, unknown test: {args.test}") +args = parse_args() script_dir = os.path.dirname(os.path.realpath(__file__)) log_dir = os.path.join(script_dir, "run") @@ -88,40 +38,22 @@ formatter = logging.Formatter(LOGGING_FORMAT) console.setFormatter(formatter) logging.getLogger('').addHandler(console) -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] cmd = f'{INSTALL_DIR}/{EXECUTABLE}' -argstr = f"-width={w} -height={h} -{args.test} -logfile_in_app_folder " -if args.benchmark == "true": - argstr += "-benchmark" -print(cmd) -print(argstr) +h, w = parse_resolution(args.resolution) +argstr = create_arg_string(w, h, args.test, args.benchmark) + with Popen([cmd, argstr]) as process: EXIT_CODE = process.wait() -SCORE = "N/A" -# need to find "score => 1212 points" -pattern = re.compile(r"score => (\d+)") log_path = os.path.join(INSTALL_DIR, "_kombustor_log.txt") -with open(log_path, encoding="utf-8") as log: - lines = log.readlines() - for line in reversed(lines): - match = pattern.search(line) - if match: - SCORE = match.group(1) +score = parse_score(log_path) report = { - "resolution": f"{w}x{h}", - "graphics_preset": "N/A", + "resolution": format_resolution(w, h), "test": args.test, - "score": SCORE + "score": score } -with open(os.path.join(log_dir, "report.json"), "w", encoding="utf-8") as f: - f.write(json.dumps(report)) +write_report_json(log_dir, "report.json", report)