# Path: smact/benchmarking/utilities.py
# def timeit(_func=None, *, fname=None, n=1, delim=False):
#     """Time function duration."""
# 
#     def decorator_timeit(func):
# 
#         @functools.wraps(func)
#         def wrapper_timeit(*args, **kwargs):
#             if delim:
#                 logging.info("-" * DELIM_LENGTH)
# 
#             times = []
#             for _ in range(n):
#                 t0 = time()
#                 value = func(*args, **kwargs)
#                 times.append(time() - t0)
# 
#             logging.info(f"{func.__name__} -- Average over {n} repeats = {mean(times)}s")
# 
#             if delim:
#                 logging.info("-" * DELIM_LENGTH)
#             return value
# 
#         return wrapper_timeit
# 
#     fname = 'benchmark.log' if not fname else fname
#     logging.basicConfig(filename=fname)
# 
#     if _func is None:
#         return decorator_timeit
#     else:
#         return decorator_timeit(_func)


from itertools import combinations_with_replacement as cwr
from pymatgen.analysis.structure_prediction.substitution_probability import SubstitutionProbability
from .utilities import timeit

"""Benchmarking functions for pymatgen."""




class ProbabilityBenchmarker:
    """Benchmarking tests for pymatgen SubstitutionProbability."""

    @timeit
    def run_tests(self):
        """Run all tests."""
        self.__sp_setup()
        self.__pair_corr()

    @timeit
    def __sp_setup(self):
        """Set up SubstitutionProbability."""
        self.sp = SubstitutionProbability()


# Path: smact/benchmarking/utilities.py
# def timeit(_func=None, *, fname=None, n=1, delim=False):
#     """Time function duration."""
# 
#     def decorator_timeit(func):
# 
#         @functools.wraps(func)
#         def wrapper_timeit(*args, **kwargs):
#             if delim:
#                 logging.info("-" * DELIM_LENGTH)
# 
#             times = []
#             for _ in range(n):
#                 t0 = time()
#                 value = func(*args, **kwargs)
#                 times.append(time() - t0)
# 
#             logging.info(f"{func.__name__} -- Average over {n} repeats = {mean(times)}s")
# 
#             if delim:
#                 logging.info("-" * DELIM_LENGTH)
#             return value
# 
#         return wrapper_timeit
# 
#     fname = 'benchmark.log' if not fname else fname
#     logging.basicConfig(filename=fname)
# 
#     if _func is None:
#         return decorator_timeit
#     else:
#         return decorator_timeit(_func)


# Path: smact/benchmarking/pymatgen_benchmark.py
from itertools import combinations_with_replacement as cwr
from pymatgen.analysis.structure_prediction.substitution_probability import SubstitutionProbability
from .utilities import timeit

"""Benchmarking functions for pymatgen."""




class ProbabilityBenchmarker:
    """Benchmarking tests for pymatgen SubstitutionProbability."""

    @timeit
    def run_tests(self):
        """Run all tests."""
        self.__sp_setup()
        self.__pair_corr()

    @timeit
    def __sp_setup(self):
        """Set up SubstitutionProbability."""
        self.sp = SubstitutionProbability()


    @timeit
