"""Functions for profiling the application.""" from contextlib import contextmanager import logging import timeit @contextmanager def measure_time(title=''): """Measure the execution time of a code block. Args: title (str): Title to be placed in logs """ start = timeit.default_timer() try: yield finally: end = timeit.default_timer() - start logging.debug('%s: elapsed seconds: %.2f', title, end)