mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-08 21:48:00 -05:00
initial commit
This commit is contained in:
13
godot_compile/README.md
Normal file
13
godot_compile/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Godot Compile
|
||||
|
||||
Compile test which measures the duration to compile Godot from source.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.10+
|
||||
|
||||
## Output
|
||||
|
||||
report.json
|
||||
- `score`: duration of compile in seconds
|
||||
- `version`: version of Godot compiled
|
||||
97
godot_compile/godot_compile.py
Normal file
97
godot_compile/godot_compile.py
Normal file
@@ -0,0 +1,97 @@
|
||||
"""godot compile test script"""
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from pathlib import Path
|
||||
from subprocess import Popen
|
||||
from godot_compile_utils import convert_duration_string_to_seconds, copy_godot_source_from_network_drive, create_conda_environment, install_mingw, install_miniconda, run_conda_command
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], ".."))
|
||||
|
||||
from handbrake.handbrake_utils import current_time_ms
|
||||
from harness_utils.output import write_report_json, DEFAULT_LOGGING_FORMAT, DEFAULT_DATE_FORMAT
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
LOG_DIR = SCRIPT_DIR.joinpath("run")
|
||||
|
||||
def setup_logging():
|
||||
"""Configures root logger"""
|
||||
LOG_DIR.mkdir(exist_ok=True)
|
||||
logging.basicConfig(filename=f'{LOG_DIR}/harness.log',
|
||||
format=DEFAULT_LOGGING_FORMAT,
|
||||
datefmt=DEFAULT_DATE_FORMAT,
|
||||
level=logging.DEBUG)
|
||||
console = logging.StreamHandler()
|
||||
formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT)
|
||||
console.setFormatter(formatter)
|
||||
logging.getLogger('').addHandler(console)
|
||||
|
||||
|
||||
def main():
|
||||
"""test script entry point"""
|
||||
setup_logging()
|
||||
output = install_mingw()
|
||||
logging.info(output)
|
||||
|
||||
output = install_miniconda()
|
||||
logging.info(output)
|
||||
|
||||
output = copy_godot_source_from_network_drive()
|
||||
logging.info(output)
|
||||
|
||||
output = create_conda_environment()
|
||||
logging.info(output)
|
||||
|
||||
output = run_conda_command(["pip", "install", "scons"])
|
||||
logging.info(output)
|
||||
|
||||
output = run_conda_command([
|
||||
"scons",
|
||||
"--clean",
|
||||
"--no-cache",
|
||||
"platform=windows",
|
||||
"arch=x86_64"
|
||||
])
|
||||
logging.info(output)
|
||||
|
||||
start_time = current_time_ms()
|
||||
output = run_conda_command([
|
||||
"scons",
|
||||
"--no-cache",
|
||||
"platform=windows",
|
||||
"arch=x86_64"
|
||||
])
|
||||
logging.info(output)
|
||||
end_time = current_time_ms()
|
||||
|
||||
score_regex = r'Time elapsed: (\d\d:\d\d:\d\d\.\d+)'
|
||||
score = None
|
||||
for line in output.splitlines():
|
||||
score_match = re.search(score_regex, line.strip())
|
||||
if score_match:
|
||||
duration_string = score_match.group(1)
|
||||
score = convert_duration_string_to_seconds(duration_string)
|
||||
break
|
||||
|
||||
if score is None:
|
||||
raise Exception("could not find score from scons output, check log and try again")
|
||||
|
||||
report = {
|
||||
"start_time": start_time,
|
||||
"version": "4.2.1-stable",
|
||||
"end_time": end_time,
|
||||
"score": score,
|
||||
"unit": "seconds",
|
||||
"test": "Godot 4.2.1 Compile"
|
||||
}
|
||||
|
||||
write_report_json(LOG_DIR, "report.json", report)
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except Exception as ex:
|
||||
logging.error("error running benchmark")
|
||||
logging.error(ex)
|
||||
sys.exit(1)
|
||||
122
godot_compile/godot_compile_utils.py
Normal file
122
godot_compile/godot_compile_utils.py
Normal file
@@ -0,0 +1,122 @@
|
||||
"""godot compile utility functions"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import List
|
||||
from zipfile import ZipFile
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
MINICONDA_INSTALLER = "Miniconda3-24.5.0-0-Windows-x86_64.exe"
|
||||
MINGW_ZIP = "x86_64-13.2.0-release-posix-seh-msvcrt-rt_v11-rev1.zip"
|
||||
MINGW_FOLDER = SCRIPT_DIR.joinpath("mingw64")
|
||||
MINICONDA_EXECUTABLE_PATH = Path("C:\\ProgramData\\miniconda3\\_conda.exe")
|
||||
CONDA_ENV_NAME = "godotbuild"
|
||||
|
||||
|
||||
def install_mingw() -> str:
|
||||
"""copies mingw from the network drive and adds to path"""
|
||||
if MINGW_FOLDER.is_dir():
|
||||
return "existing mingw installation detected"
|
||||
source = Path("\\\\Labs\\labs\\01_Installers_Utilities\\MinGW\\" + MINGW_ZIP)
|
||||
destination = SCRIPT_DIR.joinpath(MINGW_ZIP)
|
||||
shutil.copyfile(source, destination)
|
||||
with ZipFile(destination, 'r') as zip_object:
|
||||
zip_object.extractall(path=SCRIPT_DIR)
|
||||
original_path = os.environ.get('PATH', '')
|
||||
if str(MINGW_FOLDER) not in original_path:
|
||||
os.environ['PATH'] = MINGW_FOLDER + os.pathsep + original_path
|
||||
return "installed mingw from network drive"
|
||||
|
||||
|
||||
def copy_miniconda_from_network_drive():
|
||||
"""copies miniconda installer from network drive"""
|
||||
source = Path("\\\\Labs\\\labs\\01_Installers_Utilities\\Miniconda\\" + MINICONDA_INSTALLER)
|
||||
destination = SCRIPT_DIR.joinpath(MINICONDA_INSTALLER)
|
||||
shutil.copyfile(source, destination)
|
||||
|
||||
|
||||
def install_miniconda() -> str:
|
||||
"""installs miniconda from the network drive, returns install process output"""
|
||||
if MINICONDA_EXECUTABLE_PATH.exists():
|
||||
return "existing miniconda installation detected"
|
||||
copy_miniconda_from_network_drive()
|
||||
command =[
|
||||
"powershell"
|
||||
"start",
|
||||
"/wait",
|
||||
MINICONDA_INSTALLER,
|
||||
"/InstallationType=AllUsers",
|
||||
"/AddToPath=1"]
|
||||
output = subprocess.check_output(command, stderr=subprocess.PIPE, text=True)
|
||||
return output
|
||||
|
||||
|
||||
def copy_godot_source_from_network_drive() -> str:
|
||||
"""copies godot source files from the network drive"""
|
||||
if SCRIPT_DIR.joinpath("godot-4.2.1-stable").is_dir():
|
||||
return "existing godot source directory detected"
|
||||
zip_name = "godot-4.2.1-stable.zip"
|
||||
source = Path("\\\\Labs\\labs\\03_ProcessingFiles\\Godot Files\\" + zip_name)
|
||||
destination = SCRIPT_DIR.joinpath(zip_name)
|
||||
shutil.copyfile(source, destination)
|
||||
with ZipFile(destination, 'r') as zip_object:
|
||||
zip_object.extractall(path=SCRIPT_DIR)
|
||||
return "godot source copied and unpacked from network drive"
|
||||
|
||||
|
||||
def check_conda_environment_exists() -> bool:
|
||||
"""check if godotbuild environment exists"""
|
||||
command = [
|
||||
MINICONDA_EXECUTABLE_PATH,
|
||||
"list",
|
||||
"-n",
|
||||
CONDA_ENV_NAME
|
||||
]
|
||||
process = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
if process.returncode == 1:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def create_conda_environment() -> str:
|
||||
"""create conda environment to work in"""
|
||||
if check_conda_environment_exists():
|
||||
return "godotbuild conda environment exists"
|
||||
command = [
|
||||
MINICONDA_EXECUTABLE_PATH,
|
||||
"create",
|
||||
"-n",
|
||||
CONDA_ENV_NAME,
|
||||
"python=3.11"
|
||||
]
|
||||
output = subprocess.check_output(command, stderr=subprocess.PIPE, text=True)
|
||||
return output
|
||||
|
||||
|
||||
def run_conda_command(conda_cmd: List[str]) -> str:
|
||||
"""run a command inside a conda environment, returns captured output from the command"""
|
||||
command = [
|
||||
MINICONDA_EXECUTABLE_PATH,
|
||||
"run",
|
||||
"-n",
|
||||
"godotbuild",
|
||||
"--cwd",
|
||||
str(SCRIPT_DIR.joinpath("godot-4.2.1-stable")),
|
||||
] + conda_cmd
|
||||
output = subprocess.check_output(command, stderr=subprocess.PIPE, text=True)
|
||||
return output
|
||||
|
||||
|
||||
def convert_duration_string_to_seconds(duration: str) -> int:
|
||||
"""convert duration in HH:MM:SS.xxx format to total seconds"""
|
||||
time_obj = timedelta(
|
||||
hours=int(duration.split(':')[0]),
|
||||
minutes=int(duration.split(':')[1]),
|
||||
seconds=float(duration.split('.')[0].split(':')[2]),
|
||||
milliseconds=int(float('0.' + duration.split('.')[1])*1000))
|
||||
|
||||
return round(time_obj.total_seconds())
|
||||
Reference in New Issue
Block a user