Created
March 7, 2019 08:56
-
-
Save RomanSteinberg/90c851e28e758425cd864e8d63576e7f to your computer and use it in GitHub Desktop.
Scheme to run application with profiling and without
This file contains hidden or 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 yaml | |
def get_option(): | |
# get option from config or env or something | |
return yaml.load(open('config.yaml'))['production'] | |
def measure(method): | |
# measures metrics for method | |
pass | |
def dont_measure(method): | |
method() | |
option = get_option() | |
decor = measure if option else dont_measure | |
@decor | |
def foo(): | |
pass | |
if __name__ == '__main__': | |
foo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment