scaling.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:cykdtree 作者: cykdtree 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号