繁体   English   中英

Python-timeit没有结果

[英]Python - No result from timeit

我在test.py中编写了此简单代码(在python中)。 我尝试运行timeit,没有任何错误,但是我没有任何有关运行时间的信息。 你能帮助我吗 ?

import timeit

def functionsWhile():
    "Desc about function"
    lic = 0
    n = 30000
    while lic<= n:
            lic += 1
    #print "test"
    return lic

t = timeit.Timer("functionsWhile()", "from __main__ import functionsWhile")

try:
    t.repeat(3, 2)
except:
    t.print_exc()

我希望得到一个类似(EXAMPLE)的结果:

$>python test.py
[0.006793975830078125, 0.006793975830078125, 0.006793975830078125]
$>

但是我只有:

$>python test.py
$>

我没有时间的结果。 我使用python 2.7和linux。

尝试print t.repeat的结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM