first draft for testing

This commit is contained in:
Nikolas
2024-04-15 11:43:23 -07:00
parent 2497c797e6
commit a761abccf6
3 changed files with 185 additions and 0 deletions

111
pugetbench/pugetbench.py Normal file
View File

@@ -0,0 +1,111 @@
"""pugetbench for creators test script"""
import json
import logging
import os.path
from pathlib import Path
import shutil
import sys
from argparse import ArgumentParser
import time
from subprocess import Popen
from utils import find_latest_log, find_score_in_log
sys.path.insert(1, os.path.join(sys.path[0], ".."))
from harness_utils.process import terminate_processes
from harness_utils.output import (
seconds_to_milliseconds,
setup_log_directory,
write_report_json,
DEFAULT_LOGGING_FORMAT,
DEFAULT_DATE_FORMAT,
)
script_dir = os.path.dirname(os.path.realpath(__file__))
log_dir = os.path.join(script_dir, "run")
setup_log_directory(log_dir)
logging.basicConfig(filename=f'{log_dir}/harness.log',
format=DEFAULT_LOGGING_FORMAT,
datefmt='%m-%d %H:%M',
level=logging.DEBUG)
console = logging.StreamHandler()
formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT)
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
executable_name = "PugetBench for Creators.exe"
def run_benchmark(application: str) -> Popen:
start_time = time.time()
executable_path = Path(f"C:\\Program Files\\PugetBench for Creators\\{executable_name}")
command_args = ["--run_count" , "1", "--rerun_count", "1", "--benchmark_version", "1.0.0", "--preset", "Standard"]
photoshop_args = command_args + ["--app", "photoshop"]
premiere_args = command_args + ["--app", '"Premiere Pro"']
process = None
if application == "premiere":
process = Popen([executable_path] + premiere_args)
elif application == "photoshop":
process = Popen([executable_path] + photoshop_args)
exit_code = process.wait()
end_time = time.time()
return start_time, end_time, exit_code
def main():
start_time = time.time()
parser = ArgumentParser()
parser.add_argument(
"--app", dest="app", help="Host for Keras OCR service", required=True
)
args = parser.parse_args()
apps = [
"premiere",
"photoshop"
]
if args.app is None or args.app not in apps:
logging.info(f"unrecognized option for program {args.app}")
print('what')
sys.exit(1)
# 1 check if pugetbench is installed
# 2 check adobe photoshop or premiere is present
# parse the report
# print the report
score = 0
test = ""
if args.app == "premiere":
test = "Adobe Premiere Pro"
elif args.app == "photoshop":
test = "Adobe Photoshop"
try:
start_time, end_time, exit_code = run_benchmark(args.app)
if exit_code > 0:
logging.error("Test failed!")
sys.exit(exit_code)
log_file = find_latest_log()
score = find_score_in_log(log_file)
destination = Path(script_dir) / "run" / os.path.split(log_file)[1]
shutil.copy(log_file, destination)
report = {
"start_time": seconds_to_milliseconds(start_time),
"end_time": seconds_to_milliseconds(end_time),
"test": test,
"score": score
}
write_report_json(log_dir, "report.json", report)
except Exception as e:
logging.error("Something went wrong running the benchmark!")
logging.exception(e)
terminate_processes(executable_name)
sys.exit(1)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,44 @@
Benchmark Name,PugetBench for Photoshop
Benchmark Version,1.0.0
Application Name,Photoshop
Application Version,25.6
System Specs:
System,ASUS,System Product Name
OS,Microsoft Corporation,Microsoft Windows 11 Pro,22631
CPU,GenuineIntel,12th Gen Intel Core i5-12600K,10
Motherboard,ASUSTeK COMPUTER INC.,ProArt Z690-CREATOR WIFI,1720
Memory,G Skill Intl,16,GB,5200,MHz
Memory,G Skill Intl,16,GB,5200,MHz
GPU,"Parsec Cloud, Inc.",Parsec Virtual Display Adapter,0.41.0.0
GPU,NVIDIA,NVIDIA GeForce RTX 4070,31.0.15.5176
Engine
Benchmark Results:
Test,Setting,Result,Units
Overall Score (Standard),,7097,
General Score (Standard),General,73,
Filter Score (Standard),Filter,69,
File Open - RAW,General,1.53,seconds
Resize to 150MP - Preserve Details,General,1.98,seconds
Resize to 150MP - Bicubic Smooth,General,0.63,seconds
Rotate,General,1.08,seconds
Select Subject,General,3.18,seconds
Select and Mask,General,3.78,seconds
Convert to Smart Object,General,1.79,seconds
Paint Bucket,General,1.15,seconds
Smudge Tool,General,12.41,seconds
Adaptive Wide Angle,Filter,120.3,seconds
Camera Raw,Filter,3.25,seconds
Lens Correction,Filter,26.78,seconds
Content Aware Fill,Filter,8.84,seconds
Reduce Noise,Filter,11.66,seconds
Smart Sharpen,Filter,1.31,seconds
Iris Blur,Filter,7.35,seconds
Field Blur,Filter,9.38,seconds
File Save - JPG,General,1.6,seconds
File Save - PNG,General,61.37,seconds
File Save - PSD,General,25.77,seconds
File Open - PSD,General,5.4,seconds
1 Benchmark Name PugetBench for Photoshop
2 Benchmark Version 1.0.0
3 Application Name Photoshop
4 Application Version 25.6
5 System Specs:
6 System ASUS System Product Name
7 OS Microsoft Corporation Microsoft Windows 11 Pro 22631
8 CPU GenuineIntel 12th Gen Intel Core i5-12600K 10
9 Motherboard ASUSTeK COMPUTER INC. ProArt Z690-CREATOR WIFI 1720
10 Memory G Skill Intl 16 GB 5200 MHz
11 Memory G Skill Intl 16 GB 5200 MHz
12 GPU Parsec Cloud, Inc. Parsec Virtual Display Adapter 0.41.0.0
13 GPU NVIDIA NVIDIA GeForce RTX 4070 31.0.15.5176
14 Engine
15 Benchmark Results:
16 Test Setting Result Units
17 Overall Score (Standard) 7097
18 General Score (Standard) General 73
19 Filter Score (Standard) Filter 69
20 File Open - RAW General 1.53 seconds
21 Resize to 150MP - Preserve Details General 1.98 seconds
22 Resize to 150MP - Bicubic Smooth General 0.63 seconds
23 Rotate General 1.08 seconds
24 Select Subject General 3.18 seconds
25 Select and Mask General 3.78 seconds
26 Convert to Smart Object General 1.79 seconds
27 Paint Bucket General 1.15 seconds
28 Smudge Tool General 12.41 seconds
29 Adaptive Wide Angle Filter 120.3 seconds
30 Camera Raw Filter 3.25 seconds
31 Lens Correction Filter 26.78 seconds
32 Content Aware Fill Filter 8.84 seconds
33 Reduce Noise Filter 11.66 seconds
34 Smart Sharpen Filter 1.31 seconds
35 Iris Blur Filter 7.35 seconds
36 Field Blur Filter 9.38 seconds
37 File Save - JPG General 1.6 seconds
38 File Save - PNG General 61.37 seconds
39 File Save - PSD General 25.77 seconds
40 File Open - PSD General 5.4 seconds

30
pugetbench/utils.py Normal file
View File

@@ -0,0 +1,30 @@
import re
import os
from pathlib import Path
def find_latest_log():
appdata_path = os.getenv('LOCALAPPDATA')
puget_lunch_dir = Path(appdata_path) / "com.puget.benchmark" / "csv"
files = [os.path.join(puget_lunch_dir, file) for file in os.listdir(
puget_lunch_dir) if os.path.isfile(os.path.join(puget_lunch_dir, file))]
latest_file = max(files, key=os.path.getmtime)
script_dir = os.path.dirname(os.path.realpath(__file__))
return Path(script_dir) / latest_file
def find_score_in_log(log_path):
with open(log_path, 'r') as file:
for line in file:
score = is_score_line(line)
if score is not None:
return score
def is_score_line(line):
regex_pattern = r"^Overall Score.+,+(\d+),+"
match = re.search(regex_pattern, line)
if match and len(match.groups()) > 0:
return match.group(1)
else:
return None