Python timeit 模块,default_number() 实例源码
我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用timeit.default_number()。
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
def timeit(self, self.timer)
finally:
if gcold:
gc.enable()
return timing
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
def timeit(self, self.timer)
finally:
if gcold:
gc.enable()
return timing
def timeit(self, self.timer)
finally:
if gcold:
gc.enable()
return timing
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。