Update harness (#8)

This commit is contained in:
nharris-lmg
2023-09-15 11:14:18 -07:00
committed by GitHub
parent 678fe04f3d
commit f9b8e44be4
6 changed files with 1491 additions and 84 deletions

View File

@@ -1,64 +1,74 @@
"""7-Zip test script"""
import json
import logging
import os.path
import io
import re
import glob
import time
from subprocess import Popen
import subprocess
EXECUTABLE = "7zr.exe"
ABS_EXECUTABLE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), EXECUTABLE)
if os.path.isfile(ABS_EXECUTABLE_PATH) is False:
raise ValueError('No FLAC installation detected! Default installation expected to be present on the system.')
import requests
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_FORMAT = '%(asctime)s %(levelname)-s %(message)s'
logging.basicConfig(filename=f'{log_dir}/harness.log',
format=logging_format,
format=LOGGING_FORMAT,
datefmt='%m-%d %H:%M',
level=logging.DEBUG)
console = logging.StreamHandler()
formatter = logging.Formatter(logging_format)
formatter = logging.Formatter(LOGGING_FORMAT)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
# omit the first arg which is the script name
command = f'{ABS_EXECUTABLE_PATH}'
EXECUTABLE = "7zr.exe"
DOWNLOAD_URL = f"https://www.7-zip.org/a/{EXECUTABLE}"
ABS_EXECUTABLE_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), EXECUTABLE)
if os.path.isfile(ABS_EXECUTABLE_PATH) is False:
logging.info(
"7-Zip executable not found, downloading from %s", DOWNLOAD_URL)
r = requests.get(DOWNLOAD_URL, allow_redirects=True, timeout=120)
with open(ABS_EXECUTABLE_PATH, 'wb') as file:
file.write(r.content)
command = f'{ABS_EXECUTABLE_PATH}'
command = command.rstrip()
t1 = time.time()
args = ["b"]
logging.info(command)
logging.info(args)
process = Popen([command, "b"], cwd=os.path.dirname(os.path.realpath(__file__)), stdout=subprocess.PIPE)
list_of_strings = [x.decode('utf-8').rstrip('\n') for x in iter(process.stdout.readlines())]
# exit_code = process.wait()
logging.info("Starting 7-Zip benchmark! This may take a minute or so...")
process = Popen([command, "b"], cwd=os.path.dirname(
os.path.realpath(__file__)), stdout=subprocess.PIPE)
list_of_strings = [x.decode('utf-8').rstrip('\n')
for x in iter(process.stdout.readlines())]
EXIT_CODE = process.wait()
speed_pattern = '^Avr:\s*([0-9]*)\s.*\|\s*([0-9]*)\s.*$'
SPEED_PATTERN = '^Avr:\s*([0-9]*)\s.*\|\s*([0-9]*)\s.*$'
VERSION_PATTERN = '7-Zip \(r\) (.*)\('
speedC = ""
speedD = ""
VERSION = ""
SPEED_C = ""
SPEED_D = ""
# Strips the newline character
for line in list_of_strings:
print(line)
if ('Avr:' in line):
speedC = re.match(speed_pattern, line).group(1)
speedD = re.match(speed_pattern, line).group(2)
if line.isspace():
continue
logging.info(line.strip())
if '7-Zip' in line:
VERSION = re.match(VERSION_PATTERN, line).group(1)
if 'Avr:' in line:
SPEED_C = re.match(SPEED_PATTERN, line).group(1)
SPEED_D = re.match(SPEED_PATTERN, line).group(2)
t2 = time.time()
logging.info(f"Benchmark took {round((t2 - t1), 3)} seconds")
logging.info("Benchmark took %s seconds", round((t2 - t1), 3))
result = {
"score": speedC + " Compression (KiB/s) | " + speedD + " Decompression (KiB/s)"
"score": SPEED_C + " Compression (KiB/s) | " + SPEED_D + " Decompression (KiB/s)",
"version": VERSION.strip()
}
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(result))

Binary file not shown.

View File

@@ -1,58 +1,13 @@
# FurMark Test Harness
# 7-Zip Compression and Decompression Test
A benchmark which uses the built in benchmark utility of 7-Zip. It uses dummy data and then LZMA to compress/decompress it.
## Prerequisites
- Python 3.10+
- FurMark installed and on path.
This harness expects that FurMark has been installed on the system using installer defaults.
> Note: Hopefully it will install itself in the future if not present.
## Setup
1. Follow the setup instructions for the framework. If you have done so, all required python dependencies *should* be installed.
2. Install FurMark from https://geeks3d.com/furmark/downloads/
1. Follow the installer's defaults.
## Configuration
Below is an example use of this harness as a test in a benchmark configuration.
```yaml
...
...
tests:
- name: furmark
executable: "furmark.py"
process_name: "FurMark.exe"
output_dir: "run"
args:
- "/nogui"
- "/nomenubar"
- "/noscore"
- "/width=640"
- "/height=480"
- "/msaa=4"
- "/run_mode=1"
- "/max_time=10000"
- "/log_temperature"
- "/disable_catalyst_warning"
```
__name__ : _(required)_ name of the test. This much match the name of a directory in the harness folder so the framework
can find the executable and any supplementary files.
__executable__ : _(required)_ the entry point to the test harness. In this case a python script.
__process_name__ : _(required)_ The process name that should be the target for FPS recording (ex: PresentMon).
__output_dir__: _(optional)_ Directory containing files to aggregate copies of after a successful test run. If a directory path is
given, the contents are copied.
__args__ : _(optional)_ list of arguments to be appended to the command to execute. All the arguments will be passed to
the executable when invoked by the framework.
Arguments for this harness are the same
as [the documented CLI arguments](https://www.geeks3d.com/20081123/geeks3d-howto-know-furmarks-command-line-parameters/)
.
## Output
report.json
- `score`: the compression and decompression score from the test each in KiB/s
- `version`: version of 7-Zip used.

View File

@@ -11,7 +11,7 @@ Welcome to the official MarkBench testing platform developed by the LTT Labs tea
- [Prerequisites](#prerequisites)
- [Python 3.10+](#python-310)
- [Poetry](#poetry)
- [Running your first test](#running-your-first-test)
- [Downloading dependencies](#downloading-dependencies)
- [A test and its harness](#a-test-and-its-harness)
- [Creating a test harness](#creating-a-test-harness)
- [Tools in the toolbox](#tools-in-the-toolbox)
@@ -42,8 +42,15 @@ Open a powershell terminal and execute the following command to download and exe
```
After installation you will want to add poetry to the path. On Windows this path to add is `%APPDATA%\Python\Scripts`. Test that poetry is working by executing `poetry --version`, a version number should be returned, not an error.
##### Downloading dependencies
1. Open a terminal in the root directory.
2. Execute `poetry install`
Poetry installs dependencies into virtual environments. You can read more about [managing poetry environments here.](https://python-poetry.org/docs/managing-environments/).
<p align="right">(<a href="#readme-top">back to top</a>)</p>
<!-- omit in toc -->
### Running your first test
Once you've successfully installed Python and Poetry, it's time to kick off our initial test. We'll begin by launching MSI Kombustor, which serves as our primary choice for testing and exploring new MarkBench functionalities. MSI Kombustor provides an excellent starting point for acquainting yourself with our test harnesses, as it doesn't necessitate any additional automation tools from our toolkit.

1398
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

37
pyproject.toml Normal file
View File

@@ -0,0 +1,37 @@
[tool.poetry]
name = "markbench-tests"
version = "1.0.0"
description = ""
authors = []
[tool.poetry.dependencies]
python = "^3.10"
pywinauto = "0.6.8"
pyyaml = "6.0"
python-dotenv = "0.20.0"
pyfiglet = "0.8.post1"
PyAutoGUI = "^0.9.53"
PyDirectInput = "^1.0.4"
opencv-python = "^4.5.5"
Pillow = "^9.1.1"
psutil = "^5.9.1"
pandas = "^1.4.2"
imutils = "^0.5.4"
matplotlib = "^3.5.2"
protobuf = "^4.21.2"
WMI = "^1.5.1"
mss = "^7.0.1"
requests = "^2.28.2"
[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
coverage = "^6.3.3"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
# https://docs.pytest.org/en/6.2.x/reference.html#ini-options-ref
[tool.pytest.ini_options]
testpaths = ["./tests"]