简体   繁体   English

Python-timeit没有结果

[英]Python - No result from timeit

I wrote this simple code (in python) in test.py. 我在test.py中编写了此简单代码(在python中)。 I try to run timeit and I don't have any errors but I don't get any information about the time of run. 我尝试运行timeit,没有任何错误,但是我没有任何有关运行时间的信息。 Can you help me ? 你能帮助我吗 ?

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()

I expect a result such as (EXAMPLE): 我希望得到一个类似(EXAMPLE)的结果:

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

But I have only: 但是我只有:

$>python test.py
$>

I don't have result from timeit. 我没有时间的结果。 I use python 2.7 and linux. 我使用python 2.7和linux。

尝试print t.repeat的结果。

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

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