Skip to content

Instantly share code, notes, and snippets.

@x
Created June 21, 2015 22:41
Show Gist options
  • Save x/57929164049c8dffe36e to your computer and use it in GitHub Desktop.
Save x/57929164049c8dffe36e to your computer and use it in GitHub Desktop.
cprofile decorator
import cProfile
def with_profile(fn):
def _profile_fn(*args, **kwargs):
prof = cProfile.Profile()
ret = prof.runcall(fn, *args, **kwargs)
print "profile for:", fn.__name__
prof.print_stats()
return ret
return _profile_fn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment