Skip to content

Instantly share code, notes, and snippets.

@RomanSteinberg
Created March 7, 2019 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomanSteinberg/90c851e28e758425cd864e8d63576e7f to your computer and use it in GitHub Desktop.
Save RomanSteinberg/90c851e28e758425cd864e8d63576e7f to your computer and use it in GitHub Desktop.
Scheme to run application with profiling and without
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