Skip to content

Instantly share code, notes, and snippets.

@kalloc
Created December 21, 2011 17:25
Show Gist options
  • Save kalloc/1506859 to your computer and use it in GitHub Desktop.
Save kalloc/1506859 to your computer and use it in GitHub Desktop.
import time
def tracktime(f):
import time
def x(*a, **kw):
start = time.time()
res = f(*a, **kw)
print 'code work %d ms time'%((time.time()-start)*10**3)
return res
return x
@tracktime
def sleep(second):
print 'try to sleep %f sec' % (second)
time.sleep(second)
sleep(1)
sleep(0.01)
sleep(0.001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment