Skip to content

Instantly share code, notes, and snippets.

@un1t
Forked from kylegibson/profile_each_line.py
Last active October 16, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save un1t/f2fe3a467bc209babbbb to your computer and use it in GitHub Desktop.
Save un1t/f2fe3a467bc209babbbb to your computer and use it in GitHub Desktop.
from decorator import decorator
from line_profiler import LineProfiler
@decorator
def profile_each_line(func, *args, **kwargs):
profiler = LineProfiler()
profiled_func = profiler(func)
try:
return profiled_func(*args, **kwargs)
finally:
profiler.print_stats()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment