Skip to content

Instantly share code, notes, and snippets.

@rlizzo
Created November 28, 2018 04:32
Show Gist options
  • Save rlizzo/0b45568f17a81a522795aa42400f7af0 to your computer and use it in GitHub Desktop.
Save rlizzo/0b45568f17a81a522795aa42400f7af0 to your computer and use it in GitHub Desktop.
from line_profiler import LineProfiler
def do_profile(follow=[]):
def inner(func):
def profiled_func(*args, **kwargs):
try:
profiler = LineProfiler()
profiler.add_function(func)
for f in follow:
profiler.add_function(f)
profiler.enable_by_count()
return func(*args, **kwargs)
finally:
profiler.print_stats()
return profiled_func
return inner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment