# time a function using time.time() and the a @ function decorator
# tested with Python24 vegaseat 21aug2005
import time
def print_timing(func):
def wrapper(*arg):
t1 = time.time()
res = func(*arg)
t2 = time.time()
print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
return res
return wrapper
# declare the @ decorator just before the function, invokes print_timing()
@print_timing
def getPrimeList(n):
""" returns a list of prime numbers from 2 to
prime numbers from 2 to
希望本文所述对大家的Python程序设计有所帮助。
查看更多关于python定时执行指定函数的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did88837