File indexing completed on 2026-07-26 08:22:17
0001
0002
0003
0004
0005 import tempfile
0006 import pathlib
0007 import typing
0008 import logging
0009 import time
0010
0011 from . import types, build, profile, parse_profile
0012
0013 log = logging.getLogger("traccc_benchmark")
0014
0015
0016 def run_benchmark(
0017 source_dir: pathlib.Path,
0018 data_dir: pathlib.Path,
0019 commit,
0020 gpu_spec: types.GpuSpec,
0021 parallel: int = 1,
0022 events: int = 1,
0023 ncu_wrapper: str = None,
0024 cc: typing.Union[str, tuple[str, str]] = None,
0025 ):
0026 with tempfile.TemporaryDirectory() as tmpdirname:
0027 tmppath = pathlib.Path(tmpdirname)
0028
0029 log.info('Created temporary directory "%s"', str(tmppath))
0030
0031 build_dir = tmppath / "build"
0032
0033 log.info('Building traccc into build directory "%s"', build_dir)
0034
0035 log.info("Running configuration step")
0036
0037 start_time = time.time()
0038
0039 build.configure(source_dir, build_dir, commit, cc=cc)
0040
0041 end_time = time.time()
0042
0043 log.info(
0044 "Completed configuration step in %.1f seconds",
0045 end_time - start_time,
0046 )
0047
0048 log.info("Running build step with %d thread(s)", parallel)
0049
0050 start_time = time.time()
0051
0052 build.build(build_dir, parallel=parallel)
0053
0054 end_time = time.time()
0055
0056 log.info("Completed build step in %.1f seconds", end_time - start_time)
0057
0058 log.info("Running benchmark step")
0059
0060 start_time = time.time()
0061
0062 profile.run_profile(
0063 build_dir,
0064 data_dir=data_dir,
0065 commit=commit,
0066 events=events,
0067 ncu_wrapper=ncu_wrapper,
0068 )
0069
0070 end_time = time.time()
0071
0072 log.info("Completed benchmark step in %.1f seconds", end_time - start_time)
0073
0074 log.info("Running data processing step")
0075
0076 start_time = time.time()
0077
0078 result_df = parse_profile.parse_profile_ncu(
0079 build_dir / "profile.ncu-rep",
0080 gpu_spec,
0081 )
0082
0083 end_time = time.time()
0084
0085 log.info(
0086 "Completed data processing step in %.1f seconds",
0087 end_time - start_time,
0088 )
0089
0090 return result_df