[root@node110 decorator]# cat temp.py
#!/usr/bin/env python
import time
def sayhi():
print 'hi yoursister...'
time.sleep(0.1)
def time_counter(func):
def wrapper():
start =time.time()
func()
end =time.time()
print 'Thisfunction costs:',end-start
return wrapper
sayhi=time_counter(sayhi)
sayhi()