Skip to content

Instantly share code, notes, and snippets.

@bukzor
Created February 21, 2012 23:26
Show Gist options
  • Save bukzor/1879776 to your computer and use it in GitHub Desktop.
Save bukzor/1879776 to your computer and use it in GitHub Desktop.
Demonstrate difficulty with profiling and decorators
from time import sleep
def decorator(func):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
wrapper.__name__ += '_' + func.__name__
return wrapper
@decorator
def d1():
sleep(1)
@decorator
def d2():
sleep(.2)
@decorator
def d3():
sleep(.03)
def f1():
d1()
d2()
f2()
def f2():
d2()
d3()
d3()
def f3():
f1()
f2()
d3()
if __name__ == '__main__':
f1()
f2()
f3()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment