简体   繁体   中英

Python - No result from timeit

I wrote this simple code (in python) in test.py. I try to run timeit and I don't have any errors but I don't get any information about the time of run. 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):

$>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.

尝试print t.repeat的结果。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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