speed_decoding.py 文件源码

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

项目:raiden 作者: raiden-network 项目源码 文件源码
def profile_session(bias=None):
    # we are not running more than one greenlet in this test, so it's fine to
    # use python's standard profiler
    import cProfile
    import profile
    import pstats

    if bias is None:
        bias_profiler = profile.Profile()
        runs = [bias_profiler.calibrate(100000) for _ in range(5)]
        bias = min(runs)

        # the bias should be consistent, otherwise we need to increase the number of iterations
        msg = 'Bias calculations: {}, used bias: {}'.format(runs, bias)
        print(msg)

    profiler = cProfile.Profile()
    profiler.bias = bias
    profiler.enable()

    yield

    profiler.create_stats()
    stats = pstats.Stats(profiler)
    stats.strip_dirs().sort_stats('cumulative').print_stats(15)
    stats.strip_dirs().sort_stats('time').print_stats(15)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号