Created
January 6, 2020 08:04
-
-
Save allenyang79/4d9f574c2aab89f0738669c553634302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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