统计程序运行时间是time.clock()
装饰器的参数 (*args, **kwargs)
import time
def decorated_hello(func):
def _hello(*args, **kwargs):
print "<function name : " +func.__name__+">"
print "<function call begin>"
#start = time.time()
func(*args, **kwargs)
#end = time.time() - start
print "<function call end>"
print "[timecosts: %s]" % time.clock()
return _hello
@decorated_hello
def hello(name):
print "hello, %s" % name
#time.sleep(1)
hello("Richard")