speccpu: add benchdir related utils

This commit is contained in:
2025-04-23 13:36:19 +08:00
parent ce177285d5
commit 075ad5d8c8
2 changed files with 110 additions and 1 deletions

View File

@@ -117,3 +117,49 @@ class SPEC:
*(["--outputdir", str(output_root)] if output_root else []),
*benchmarks,
]
def check_bench_dir(dir: Path) -> bool:
"""
Check if a directory has the expected SPEC benchmark structure.
Parameters
----------
dir : Path
The directory to check
Returns
-------
bool
True if the directory contains 'build', 'exe', and 'run' subdirectories,
False otherwise
"""
files = os.listdir(dir)
return "build" in files and "exe" in files and "run" in files
def get_benchspec_dir(spec_output: Path) -> Path:
"""
Get the directory containing CPU benchmarks in the SPEC CPU output.
This function returns the path to the CPU benchmarks directory within the SPEC CPU
output directory structure.
Parameters
----------
spec_output : Path
The path to the SPEC CPU output directory.
Returns
-------
Path
The path to the CPU benchmarks directory.
Examples
--------
>>> from pathlib import Path
>>> spec_dir = Path("/path/to/spec/output")
>>> get_benchspec_dir(spec_dir)
PosixPath('/path/to/spec/output/benchspec/CPU')
"""
return spec_output / "benchspec" / "CPU"