Skip to content

Instantly share code, notes, and snippets.

@fsodogandji
Created July 5, 2013 15:22
Show Gist options
  • Save fsodogandji/5935262 to your computer and use it in GitHub Desktop.
Save fsodogandji/5935262 to your computer and use it in GitHub Desktop.
A simple profiling decorator
def profileit(func):
def wrapper(*args, **kwargs):
datafn = func.__name__ + ".profile"
prof = cProfile.Profile()
retval = prof.runcall(func, *args, **kwargs)
prof.dump_stats(datafn)
return retval
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment