reader.py 文件源码

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

项目:org-chart-builder 作者: Hitachi-Data-Systems 项目源码 文件源码
def timer(fn):
    """
    Create a timeit call to a function and pass in keyword arguments.
    The function is called twice, once using the standard workbook, then with the optimised one.
    Time from the best of three is taken.
    """
    print("lxml", openpyxl.LXML)
    result = []
    for opt in (False, True,):
        print("Workbook is {0}".format(opt and "optimised" or "not optimised"))
        times = timeit.repeat("{0}({1})".format(fn.__name__, opt),
                              setup="from __main__ import {0}".format(fn.__name__),
                              number = 1,
                              repeat = 3
        )
        print("{0:.2f}s".format(min(times)))
        result.append(min(times))
    std, opt = result
    print("Optimised takes {0:.2%} time\n".format(opt/std))
    return std, opt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号