微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python timeit 模块-default_number() 实例源码

Python timeit 模块,default_number() 实例源码

我们从Python开源项目中,提取了以下5代码示例,用于说明如何使用timeit.default_number()

项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
def timeit(self, number=timeit.default_number):
        """Time 'number' executions of the main statement.

        To be precise,this executes the setup statement once,and
        then returns the time it takes to execute the main statement
        a number of times,as a float measured in seconds.  The
        argument is the number of times through the loop,defaulting
        to one million.  The main statement,the setup statement and
        the timer function to be used are passed to the constructor.
        """
        it = itertools.repeat(None, number)
        gcold = gc.isenabled()
        gc.disable()
        try:
            timing = self.inner(it, self.timer)
        finally:
            if gcold:
                gc.enable()
        return timing
项目:Repobot    作者:Desgard    | 项目源码 | 文件源码
def timeit(self, self.timer)
        finally:
            if gcold:
                gc.enable()
        return timing
项目:gitsome    作者:donnemartin    | 项目源码 | 文件源码
def timeit(self, number=timeit.default_number):
        """Time 'number' executions of the main statement.
        To be precise, self.timer)
        finally:
            if gcold:
                gc.enable()
        return timing
项目:blender    作者:gastrodia    | 项目源码 | 文件源码
def timeit(self, self.timer)
        finally:
            if gcold:
                gc.enable()
        return timing
项目:yatta_reader    作者:sound88    | 项目源码 | 文件源码
def timeit(self, self.timer)
        finally:
            if gcold:
                gc.enable()
        return timing

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐