bench.py 文件源码

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

项目:deb-python-falcon 作者: openstack 项目源码 文件源码
def bench(func, iterations, stat_memory):
    gc.collect()
    heap_diff = None

    if heapy and stat_memory:
        heap_before = heapy.heap()

    total_sec = timeit.timeit(func, setup=gc.enable, number=iterations)

    if heapy and stat_memory:
        heap_diff = heapy.heap() - heap_before

    sec_per_req = Decimal(str(total_sec)) / Decimal(str(iterations))

    sys.stdout.write('.')
    sys.stdout.flush()

    return (sec_per_req, heap_diff)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号