def time_run(npart, nproc, ndim, nrep=1, periodic=False, leafsize=10,
suppress_final_output=False):
r"""Get runing times using :package:`time`.
Args:
npart (int): Number of particles.
nproc (int): Number of processors.
ndim (int): Number of dimensions.
nrep (int, optional): Number of times the run should be performed to
get an average. Defaults to 1.
periodic (bool, optional): If True, the domain is assumed to be
periodic. Defaults to False.
leafsize (int, optional): The maximum number of points that should be
in any leaf in the tree. Defaults to 10.
suppress_final_output (bool, optional): If True, the final output
from spawned MPI processes is suppressed. This is mainly for
timing purposes. Defaults to False.
"""
times = np.empty(nrep, 'float')
for i in range(nrep):
t1 = time.time()
run_test(npart, ndim, nproc=nproc,
periodic=periodic, leafsize=leafsize,
suppress_final_output=suppress_final_output)
t2 = time.time()
times[i] = t2 - t1
return np.mean(times), np.std(times)
评论列表
文章目录