Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created January 6, 2020 08:04
Show Gist options
  • Save allenyang79/4d9f574c2aab89f0738669c553634302 to your computer and use it in GitHub Desktop.
Save allenyang79/4d9f574c2aab89f0738669c553634302 to your computer and use it in GitHub Desktop.
import wrapt
import logging
@wrapt.decorator
def trace_it(wrapped, instance, args, kwargs):
import time
begin_at = time.time()
ret = wrapped(*args, **kwargs)
end_at = time.time()
logging.info(f"{wrapped.__name__} called {end_at - begin_at}")
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment